C:\Users\jowu\virtualEnvironment\Scripts\python.exe C:/Users/jowu/Desktop/PyWeb/PyWeb.py
Traceback (most recent call last):
File "C:\Users\jowu\AppData\Local\Programs\Python\Python36\lib\site-packages\werkzeug\serving.py", line 65, in <module>
from SocketServer import ThreadingMixIn, ForkingMixIn
ImportError: No module named 'SocketServer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/jowu/Desktop/PyWeb/PyWeb.py", line 12, in <module>
app.run()
File "C:\Users\jowu\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 828, in run
from werkzeug.serving import run_simple
File "C:\Users\jowu\AppData\Local\Programs\Python\Python36\lib\site-packages\werkzeug\serving.py", line 68, in <module>
from socketserver import ThreadingMixIn, ForkingMixIn
ImportError: cannot import name 'ForkingMixIn'
Process finished with exit code 1
大家讲道理2017-04-18 09:21:03
werkzeug的一個bug。
https://github.com/pallets/we...
在python36後就有的,用python35吧。
樓下那個答案說的不對,因為./Python36/lib/site-packages/werkzeug/serving.py的寫法如下:
try:
from SocketServer import ThreadingMixIn, ForkingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
except ImportError:
from socketserver import ThreadingMixIn, ForkingMixIn
from http.server import HTTPServer, BaseHTTPRequestHandler
所以不存在大小寫的問題。
天蓬老师2017-04-18 09:21:03
Python3以後,SocketServer這個模組的命名變成了socketserver。
在Python2.7的文檔開頭的NOTE裡面就有寫:
SocketServer — A framework for network servers
我是使用的2.7的Python,所以也沒有嘗試過,建議把模組的名字改一下再試試。
阿神2017-04-18 09:21:03
這種問題先進入virtualenv直接進在命令列敲python, 進去之後直接import SocketServer 看能不能導入,不能就肯定是名字錯了或者缺包。