要求时,Django API引发错误“无此文件或目录:'manage.py'”

时间:2018-08-24 10:35:54

标签: python django django-manage.py manage.py

这似乎是一个已经被问到的问题,但是我已经搜索了一个星期的答案,却一无所获。 问题是我已经使用托管在服务器上的Django开发了API。现在,当我运行以下命令来启动服务器时:

python manage.py runserver 0.0.0.0:9000

服务器照常启动。仅当我通过“邮递员”向服务器发送请求时,才会看到以下错误:

FileNotFoundError: [Errno 2] No such file or directory: 'manage.py'

奇怪的是,只有在我向服务器发送请求时,运行服务器才有错误。另外,我还有更多的Django API在相同的服务器上运行,它们具有相同的 python版本(Python 3.4.3)和相同的虚拟环境(但端口不同),并且运行良好。

完整错误回溯:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 61, in execute
    super().execute(*args, **options)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 98, in handle
    self.run(**options)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 105, in run
    autoreload.main(self.inner_run, None, options)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/utils/autoreload.py", line 317, in main
    python_reloader(wrapped_main_func, args, kwargs)
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/utils/autoreload.py", line 296, in python_reloader
    reloader_thread()
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/utils/autoreload.py", line 274, in reloader_thread
    change = fn()
  File "/home/ubuntu/py3env/lib/python3.4/site-packages/django/utils/autoreload.py", line 204, in code_changed
    stat = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory: 'manage.py'

我尝试过的事情:

  • 我尝试按照各种帖子的建议更改!#
  • 我尝试使用dos2unix将文件转换为unix格式(托管我的API的服务器基于linux)。
  • 我什至尝试创建一个新的Django项目。
  • 是的,我正在从正确的目录运行manage.py。
  • 我还尝试通过以下方式使manage.py可执行文件:

    chmod + x manage.py

到目前为止,对我来说什么都没有。我想念什么吗?

0 个答案:

没有答案