python NameError: name 'file' is not defined

后端 未结 4 763
情话喂你
情话喂你 2020-12-13 08:26

I dont know much about python. I want to start working on the project and the setup instruction says:

pip install -r requirements-dev.txt

S

相关标签:
4条回答
  • 2020-12-13 08:42

    To solve this error, it is enough to add from google.colab import files in your code!

    0 讨论(0)
  • 2020-12-13 08:50

    It seems that your project is written in Python < 3. This is because the file() builtin function is removed in Python 3. Try using Python 2to3 tool or edit the erroneous file yourself.

    EDIT: BTW, the project page clearly mentions that

    Gunicorn requires Python 2.x >= 2.5. Python 3.x support is planned.

    0 讨论(0)
  • 2020-12-13 08:55

    file is not defined in Python3, which you are using apparently. The package you're instaling is not suitable for Python 3, instead, you should install Python 2.7 and try again.

    See: http://docs.python.org/release/3.0/whatsnew/3.0.html#builtins

    0 讨论(0)
  • 2020-12-13 09:00

    file() is not supported in Python 3

    Use open() instead; see Built-in Functions - open().

    0 讨论(0)
提交回复
热议问题