在python 3.3中导入Process时收到以下错误。有什么理由我会得到这样的错误,还是这个错误?我在另一个终端窗口运行django服务器,但我怀疑这与此有什么关系。
Python 3.3.2 (default, Nov 8 2013, 13:38:57)
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
# extension module loaded from '/usr/lib64/python3.3/lib-dynload/readline.cpython-33m.so'
import 'readline' # <_frozen_importlib.ExtensionFileLoader object at 0x7f8a00fc1050>
>>> from multiprocessing import Process
# ./__pycache__/multiprocessing.cpython-33.pyc matches ./multiprocessing.py
# code object from ./__pycache__/multiprocessing.cpython-33.pyc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1024, in load_module
File "<frozen importlib._bootstrap>", line 1005, in load_module
File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 870, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "./multiprocessing.py", line 1, in <module>
from multiprocessing import Process
ImportError: cannot import name Process
答案 0 :(得分:24)
回溯中的行File "./multiprocessing.py"
表明您在工作目录中有一个名为multiprocessing.py
的文件。
尝试删除/重命名它,因为它会影响真正的multiprocessing
模块。这里的问题是sys.path
中的第一个条目始终为''
,因此在执行import
时,工作目录中的文件将优先于标准模块。