我是python的新手。我正在尝试导入Flask的python脚本。但这引发了错误。
这是我的python脚本“ tokenize.py ”
from flask import Flask, Response
但是运行它时出现以下错误:
$ python2.7 tokenize.py
Traceback (most recent call last):
File "tokenize.py", line 4, in <module>
from flask import Flask, Response
File "/Library/Python/2.7/site-packages/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Library/Python/2.7/site-packages/werkzeug/__init__.py", line 151, in <module>
__import__('werkzeug.exceptions')
File "/Library/Python/2.7/site-packages/werkzeug/exceptions.py", line 67, in <module>
from werkzeug._internal import _get_environ
File "/Library/Python/2.7/site-packages/werkzeug/_internal.py", line 13, in <module>
import inspect
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 39, in <module>
import tokenize
File "/Users/abashir/tokenize.py", line 4, in <module>
from flask import Flask, Response
ImportError: cannot import name Flask
我正在使用 MacOS High Sierra版本10.13.6(17G6S)。
$ python2.7 -V
Python 2.7.10
在点列表中:
$ pip list
Package Version
-------------------------------------- --------
...
Flask 1.0.2
...
当我尝试重新安装Flask时
$ pip install Flask
Requirement already satisfied: Flask in /Library/Python/2.7/site-packages (1.0.2)
Requirement already satisfied: Jinja2>=2.10 in /Library/Python/2.7/site-packages (from Flask) (2.10)
Requirement already satisfied: itsdangerous>=0.24 in /Library/Python/2.7/site-packages (from Flask) (1.1.0)
Requirement already satisfied: Werkzeug>=0.14 in /Library/Python/2.7/site-packages (from Flask) (0.14.1)
Requirement already satisfied: click>=5.1 in /Library/Python/2.7/site-packages (from Flask) (7.0)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Python/2.7/site-packages (from Jinja2>=2.10->Flask) (1.1.0)
出什么问题了?以及如何解决?