Maison > Questions et réponses > le corps du texte
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
Un bug dans werkzeug.
https://github.com/pallets/we...
Il est disponible après python36, utilisez python35.
La réponse ci-dessous est fausse car ./Python36/lib/site-packages/werkzeug/serving.py s'écrit comme suit :
try:
from SocketServer import ThreadingMixIn, ForkingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
except ImportError:
from socketserver import ThreadingMixIn, ForkingMixIn
from http.server import HTTPServer, BaseHTTPRequestHandler
Il n'y a donc pas de problème de boîtier.
天蓬老师2017-04-18 09:21:03
Après Python 3, le nom du module SocketServer a été changé en socketserver.
C'est écrit dans la NOTE au début du document Python2.7 :
SocketServer — Un framework pour les serveurs réseau
J'utilise Python 2.7, donc je ne l'ai pas essayé. Il est recommandé de changer. le nom du module. Réessayez plus tard.
阿神2017-04-18 09:21:03
Pour ce genre de problème, entrez d'abord virtualenv et tapez python directement sur la ligne de commande. Après avoir entré, importez directement SocketServer pour voir s'il peut être importé. Sinon, il doit s'agir d'un nom erroné ou d'un package. manquant.