如何将 Django 应用程序覆盖到 Pythonanywhere?

How to overwrite Django app to Pythonanywhere?

第二次将Django应用程序部署到Pythonanywhere后,(我在VS代码中重新编辑并覆盖并进行了git推送)我得到了以下错误。

WARNING: Package(s) not found: django
Traceback (most recent call last):
  File "/home/hogehohe/.local/bin/pa_autoconfigure_django.py", line 47, in <module>
    main(arguments['<git-repo-url>'], arguments['--domain'], arguments['--python'], nuke=arguments.get('--nuke'))
  File "/home/hogehohe/.local/bin/pa_autoconfigure_django.py", line 36, in main
    project.update_settings_file()
  File "/home/hogehohe/.local/lib/python3.6/site-packages/pythonanywhere/django_project.py", line 74, in update_settings_file
    new_django = version.parse(self.virtualenv.get_version("django")) >= version.parse("3.1")
  File "/home/hogehohe/.local/lib/python3.6/site-packages/pythonanywhere/virtualenvs.py", line 32, in get_version
    output = subprocess.check_output(commands).decode()
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/home/hogehohe/.virtualenvs/hogehohe.pythonanywhere.com/bin/pip', 'show', 'django']' returned non-zero exit status 1.

命令是

$ pa_autoconfigure_django.py https://github.com/[user_name]/[project_name].git --nuke

第一次部署成功,第二次部署失败。我不知道原因以及如何覆盖它...

您的项目中需要有一个 requirements.txt 文件来指定您的应用程序所需的包。我猜你的第一个项目有一个包含 django 而你的第二个项目没有。