尝试在pythonanywhere上部署并且不起作用

时间:2019-03-08 20:36:39

标签: django deployment pythonanywhere

我已经下载了pythonanywhere安装工具,并尝试使用以下行进行部署:

pa_autoconfigure_django.py <https://github.com/myusername/myproject.git>

然后,我得到一个关键错误。我的项目在本地运行。

 File "/projects/hosproject/venv/lib/python3.7/site-packages/pythonanywhere/project.py", line 16, in __init__
    self.virtualenv = Virtualenv(self.domain, self.python_version)
  File "/projects/hosproject/venv/lib/python3.7/site-packages/pythonanywhere/virtualenvs.py", line 12, in __init__
    self.path = Path(os.environ["WORKON_HOME"]) / domain
  File "/projects/hosproject/venv/bin/../lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'WORKON_HOME'

需要一些帮助来调试它,然后尝试再次部署。如果有帮助,我是Django的新手,请按照以下教程进行操作:https://tutorial.djangogirls.org/en/deploy/

1 个答案:

答案 0 :(得分:0)

As noted by Giles

  

您似乎可能正在自己的计算机上的终端上运行PythonAnywhere工具-您应该在PythonAnywhere上的bash控制台中运行它 –您可以从“控制台”中启动一个页。 (强调我的)

但是我在运行一些我本不应该使用的命令后才来到KeyError: WORKON_HOME(至少这样会使清理变得更容易):

$ pip3 install --user pythonanywhere
$ pa_autoconfigure_django.py --python=3.7 git@github.com:pzrq/djangogirls-tutorial-blog.git
-bash: pa_autoconfigure_django.py: command not found

$ find / -name "pa_autoconfigure_django.py"
$ /Users/pzrq/Library/Python/3.7/bin/pa_autoconfigure_django.py --python=3.7 git@github.com:pzrq/djangogirls-tutorial-blog.git
Traceback (most recent call last):
File "/Users/pzrq/Library/Python/3.7/bin/pa_autoconfigure_django.py", line 19, in <module>
    from docopt import docopt
ModuleNotFoundError: No module named 'docopt'

$ pip install docopt
...
$ /Users/pzrq/Library/Python/3.7/bin/pa_autoconfigure_django.py --python=3.7 git@github.com:pzrq/djangogirls-tutorial-blog.git
...
ModuleNotFoundError: No module named 'pythonanywhere'

$ pip install pythonanywhere
...
$ /Users/pzrq/Library/Python/3.7/bin/pa_autoconfigure_django.py --python=3.7 git@github.com:pzrq/djangogirls-tutorial-blog.git
Traceback (most recent call last):
  File "/Users/pzrq/Library/Python/3.7/bin/pa_autoconfigure_django.py", line 52, in <module>
    main(arguments['<git-repo-url>'], arguments['--domain'], arguments['--python'], nuke=arguments.get('--nuke'))
  File "/Users/pzrq/Library/Python/3.7/bin/pa_autoconfigure_django.py", line 33, in main
    project = DjangoProject(domain, python_version)
  File "/Users/pzrq/Projects/djangogirls/myvenv/lib/python3.7/site-packages/pythonanywhere/project.py", line 16, in __init__
    self.virtualenv = Virtualenv(self.domain, self.python_version)
  File "/Users/pzrq/Projects/djangogirls/myvenv/lib/python3.7/site-packages/pythonanywhere/virtualenvs.py", line 12, in __init__
    self.path = Path(os.environ["WORKON_HOME"]) / domain
  File "/usr/local/bin/../Cellar/python/3.7.3/bin/../Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'WORKON_HOME'