我正在运行 Python 3.5 并尝试在命令行中从 this django app 运行一些代码,这一直在发生:
C:\Users\username\Envs\mysite> python service.py --startup=auto install
Traceback (most recent call last):
File "service.py", line 14, in <module>
from django_windows_tools.service import DjangoService,test_commands
File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\django_windows_tools\service.py", line 39, in <module>
import multiprocessing.forking
ImportError: No module named 'multiprocessing.forking'
我不确定是什么原因造成的。
最佳答案
python v2.6/2.7
默认安装了 forking.py
,但没有安装 v3.5.1
[root@localhost usr]# find /usr -name multiprocessing
/usr/lib64/python2.7/multiprocessing
/usr/lib64/python3.5/multiprocessing
[root@localhost usr]# find /usr -name forking.py
/usr/lib64/python2.7/multiprocessing/forking.py
python3.5.1由于某些原因没有forking.py,你运行的包不支持python3,你可以在git repo上报告问题或用python2安装它。
[root@localhost usr]# python3
Python 3.5.1 (default, Mar 4 2016, 15:21:15)
[GCC 6.0.0 20160302 (Red Hat 6.0.0-0.14)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> import multiprocessing.forking
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'multiprocessing.forking'
虽然python2没有问题
[root@localhost usr]# python2
Python 2.7.12 (default, Sep 2 2016, 14:46:00)
[GCC 6.1.1 20160621 (Red Hat 6.1.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> import multiprocessing.forking
关于python - 导入错误 : No module named 'multiprocessing.forking' ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42265551/