【问题标题】:mayavi import UnicodeDecodeErrormayavi 导入 UnicodeDecodeError
【发布时间】: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)

【问题讨论】:

    标签: python import mayavi


    【解决方案1】:

    UnicodeDecodeError: 'ascii' 编解码器无法解码

    错误来源:

    文件“....\lib\site-packages\pyface\workbench\workbench.py​​”,第 319 行,在 _restore_window_layout

    memento = pickle.load(f)
    

    我编辑它如下,它现在可以工作了:)

    memento = pickle.load(f,encoding='latin1')
    

    【讨论】:

      猜你喜欢
      • 2015-02-20
      • 1970-01-01
      • 2020-01-30
      • 2023-03-24
      • 2020-01-15
      • 2017-01-05
      • 2012-09-26
      • 1970-01-01
      • 2012-08-26
      相关资源
      最近更新 更多