【发布时间】:2015-07-16 11:15:21
【问题描述】:
当我尝试从 mayavi 导入 mlab 并从 spyder 运行脚本时,出现 UnicodeDecodeError。
我正在运行一台 Windows 8 机器。当我搜索此问题时,我发现路径或文件名中不应包含非 ASCII 字符,但在我的示例文件 test.py 中并非如此,对于这个最小示例,该文件存储在 c:\test\
from mayavi import mlab
我在控制台中得到以下输出(不管我使用 Python 还是 IPython 控制台):
runfile('C:/test/test.py', wdir=r'C:/test')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 601, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 66, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/test/test.py", line 1, in <module>
from mayavi import mlab
File "C:\Python27\lib\site-packages\mayavi\mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "C:\Python27\lib\site-packages\mayavi\tools\camera.py", line 25, in <module>
from engine_manager import get_engine
File "C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\api.py", line 4, in <module>
from preference_manager import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 128, in <module>
preference_manager = PreferenceManager()
File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 81, in __init__
self._load_preferences()
File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 101, in _load_preferences
app_home = ETSConfig.get_application_home()
File "C:\Python27\lib\site-packages\traits\etsconfig\etsconfig.py", line 132, in get_application_home
self._get_application_dirname())
File "C:\Python27\lib\ntpath.py", line 84, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 9: ordinal not in range(128)
【问题讨论】: