python NameError:未定义名称'file'

nic*_*kik 44 python pip gunicorn

我不太了解python.我想开始研究项目,设置说明说:

pip install -r requirements-dev.txt
Run Code Online (Sandbox Code Playgroud)

简单的enougth.问题是我得到了这个:

    Downloading/unpacking gunicorn==0.13.4 (from -r requirements.txt (line 7))
  Running setup.py egg_info for package gunicorn
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-root/gunicorn/setup.py", line 18, in <module>
        long_description = file(
    NameError: name 'file' is not defined
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-build-root/gunicorn/setup.py", line 18, in <module>

    long_description = file(

NameError: name 'file' is not defined
Run Code Online (Sandbox Code Playgroud)

我不明白这个问题.也许有人可以帮忙吗?

我在Arch Linux上运行它,python默认为python 3,项目不是python 3但是我不确定是不是这样.

谢谢.

小智 127

file() Python 3不支持

使用open()代替; 请参阅内置函数 - 打开().


mg0*_*007 8

看来你的项目是用Python <3编写的.这是因为在Python 3中删除file()内置函数.尝试使用Python 2to3工具自己编辑错误的文件.

编辑:BTW,项目页面明确提到

Gunicorn需要Python 2.x> = 2.5.Python 3.x支持计划.

  • 对于声称他不熟悉Python的人,我认为尝试将Gunicorn移植到Python 3可能是一个坏主意:).它只是不起作用,使用Python 2.7是更好的选择. (3认同)

Blu*_*ber 5

显然您正在使用的Python3中未定义文件。您要安装的软件包不适用于Python 3,而是应该安装Python 2.7,然后重试。

请参阅:http : //docs.python.org/release/3.0/whatsnew/3.0.html#builtins