导入 Pylot 会导致 flask.py 中出现“无效语法”错误
Posted
技术标签:
【中文标题】导入 Pylot 会导致 flask.py 中出现“无效语法”错误【英文标题】:Importing Pylot causes "invalid syntax" error in flask.py 【发布时间】:2019-02-20 13:50:44 【问题描述】:我是 Python 新手,我想复制本教程:https://www.youtube.com/watch?v=wQ8BIBpya2k 但是当我尝试导入 Matpotlib.pylot 时出现此错误:“ModuleNotFoundError: No module named 'matplotlib.pylot'”所以现在我尝试安装Pylot 手动,但它给我一个语法错误:
D:\Python>pip3 install --upgrade --no-cache-dir pylot
Collecting pylot
Downloading https://files.pythonhosted.org/packages/6f/18/1d14c2f30b46c92c01ec3aa8499553e73e1f3258188a9abecefb784fb7a5/Pylot-0.0.4.tar.gz (2.8MB)
100% |████████████████████████████████| 2.8MB 5.1MB/s
Collecting Flask==0.10.1 (from pylot)
Downloading https://files.pythonhosted.org/packages/db/9c/149ba60c47d107f85fe52564133348458f093dd5e6b57a5b60ab9ac517bb/Flask-0.10.1.tar.gz (544kB)
100% |████████████████████████████████| 552kB 4.1MB/s
Collecting Flask-Classy==0.6.10 (from pylot)
Downloading https://files.pythonhosted.org/packages/92/07/bbe7a8aefd8799fc456f711b86952457b3e63c8aec9dfd4c911c55df9ea7/Flask-Classy-0.6.10.tar.gz
Collecting Flask-Assets==0.10 (from pylot)
Downloading https://files.pythonhosted.org/packages/95/de/88eb544c93313031e7b85758a1443730b92e7b1d01ec7222ddfea5f382e7/Flask-Assets-0.10.tar.gz
Collecting flask-recaptcha==0.3 (from pylot)
Downloading https://files.pythonhosted.org/packages/2a/fb/866560e195c499c9e6aed83f577f311cdbeeaab7d8fe0fca71d27f4ae3cb/Flask-ReCaptcha-0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\fried\AppData\Local\Temp\pip-install-z6djdn7w\flask-recaptcha\setup.py", line 3, in <module>
import flask_recaptcha
File "C:\Users\fried\AppData\Local\Temp\pip-install-z6djdn7w\flask-recaptcha\flask_recaptcha.py", line 12, in <module>
from flask import request
File "c:\users\fried\appdata\local\programs\python\python36\lib\site-packages\flask.py", line 148
except HTTPException, e:
^
SyntaxError: invalid syntax
Command "python setup.py egg_info" failed with error code 1 in C:\Users\fried\AppData\Local\Temp\pip-install-z6djdn7w\flask-recaptcha\
【问题讨论】:
【参考方案1】:matplotlib 中的模块 被称为pyplot
,而不是pylot
。 PyPI 上的 pylot
package 与 matplotlib 完全无关。
【讨论】:
以上是关于导入 Pylot 会导致 flask.py 中出现“无效语法”错误的主要内容,如果未能解决你的问题,请参考以下文章
cannot import name 'Flask' from 'flask'
在 pylot 的 testcases.xml 中编写正则表达式的问题