尝试导入mayavi时遇到了一个非常奇怪的错误。几分钟前,它就像一个魅力,但现在出现了问题,我不知道为什么。
我从终端开始python
,然后输入:
from mayavi import mlab
我得到的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/mayavi/mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/usr/lib/python2.7/dist-packages/mayavi/tools/camera.py", line 23, in <module>
from engine_manager import get_engine
File "/usr/lib/python2.7/dist-packages/mayavi/tools/engine_manager.py", line 14, in <module>
from mayavi.core.engine import Engine
File "/usr/lib/python2.7/dist-packages/mayavi/core/engine.py", line 28, in <module>
from mayavi.core.scene import Scene
File "/usr/lib/python2.7/dist-packages/mayavi/core/scene.py", line 15, in <module>
from mayavi.core.source import Source
File "/usr/lib/python2.7/dist-packages/mayavi/core/source.py", line 19, in <module>
from mayavi.core.module_manager import ModuleManager
File "/usr/lib/python2.7/dist-packages/mayavi/core/module_manager.py", line 19, in <module>
from mayavi.core.lut_manager import LUTManager
File "/usr/lib/python2.7/dist-packages/mayavi/core/lut_manager.py", line 10, in <module>
import subprocess
File "/usr/lib/python2.7/subprocess.py", line 432, in <module>
import pickle
File "pickle.py", line 4, in <module>
from mayavi import mlab
ImportError: cannot import name mlab
Python出了什么问题?
答案 0 :(得分:5)
您有一个名为pickle.py
的本地文件;这是导入而不是pickle
module。然后,该模块尝试在该模块本身完成导入循环导入依赖项之前导入mlab
:
File "/usr/lib/python2.7/subprocess.py", line 432, in <module>
import pickle
File "pickle.py", line 4, in <module>
from mayavi import mlab
请注意subprocess
如何尝试导入pickle
并找到您的文件(路径是相对的,而不是/usr/lib/python2.7/
内的完整路径。
将pickle.py
重命名为其他内容,您在此处屏蔽标准库。