无法导入名称 _args_from_interpreter_flags
当我在 OS X 10.6.8 上使用 Python 2.7.5 尝试 import multiprocessing
时,出现了这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/__init__.py", line 65, in <module>
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/util.py", line 40, in <module>
from subprocess import _args_from_interpreter_flags
ImportError: cannot import name _args_from_interpreter_flags
我还尝试用 homebrew 安装 python2.7.6,但这个错误依然存在。
1 个回答
2
听起来像是一个循环导入
的问题。试着在其他导入的代码后面加上这个:
from subprocess import _args_from_interpreter_flags
在subprocess.py
文件的函数上方有一个注释:
# XXX This function is only used by multiprocessing and the test suite,
# but it's here so that it can be imported when Python is compiled without
# threads.
这可能有关系。