Rumah > Soal Jawab > teks badan
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
Pepijat dalam werkzeug.
https://github.com/pallets/we...
Ia tersedia selepas python36, gunakan python35.
Jawapan di bawah adalah salah, kerana ./Python36/lib/site-packages/werkzeug/serving.py ditulis seperti berikut:
try:
from SocketServer import ThreadingMixIn, ForkingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
except ImportError:
from socketserver import ThreadingMixIn, ForkingMixIn
from http.server import HTTPServer, BaseHTTPRequestHandler
Jadi tiada masalah kes.
天蓬老师2017-04-18 09:21:03
Selepas Python 3, nama modul SocketServer ditukar kepada socketserver.
Ia ditulis dalam NOTA pada permulaan dokumen Python2.7:
SocketServer — Rangka kerja untuk pelayan rangkaian
Saya menggunakan Python 2.7, jadi saya belum mencubanya nama modul Cuba lagi nanti.
阿神2017-04-18 09:21:03
Untuk masalah sebegini, mula-mula masukkan virtualenv dan taip python terus pada baris arahan Selepas memasukkan, terus import SocketServer untuk melihat jika ia boleh diimport, mesti nama itu salah atau pakej hilang.