我正在关注这个 Heroku 教程:https://devcenter.heroku.com/articles/getting-started-with-python-o当我尝试在 virtualenv 中安装 gunicorn 时出现此错误:
(venv)jabuntu14@ubuntu:~/Desktop/helloflask$ pip install gunicorn
Downloading/unpacking gunicorn
Downloading gunicorn-19.1.1-py2.py3-none-any.whl (104kB): 104kB downloaded
Installing collected packages: gunicorn
Compiling /home/jabuntu14/Desktop/helloflask/venv/build/gunicorn/gunicorn/workers /_gaiohttp.py ...
File "/home/jabuntu14/Desktop/helloflask/venv/build/gunicorn/gunicorn/workers /_gaiohttp.py", line 64
yield from self.wsgi.close()
^
SyntaxError: invalid syntax
Successfully installed gunicorn
Cleaning up...
但是,当我运行 $foreman start 时,它似乎工作正常。
这个错误有多重要?知道如何解决吗?
最佳答案
错误可以忽略,你的gunicorn
包安装成功。
该错误是由一些仅适用于 Python 3.3 或更高版本的代码引发的,但 Gunicorn 支持的旧 Python 版本不使用该代码。
见 https://github.com/benoitc/gunicorn/issues/788 :
The error is a syntax error happening during install. It is harmless.
在安装过程中,setup.py
脚本会尝试收集所有要安装的文件,并将它们编译为 .pyc
字节缓存文件。仅在 Python 3.3 或更高版本上使用的一个文件包含在其中,并且该文件的编译失败。
有问题的文件增加了对 aiohttp http client/server package 的支持。 ,它只适用于 Python 3.3 及更高版本。因此,您可以完全忽略此错误。
关于python - 安装 gunicorn 的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25611140/