我刚刚创建了一个新的Django项目,将其推送到Git上,现在我正在尝试使用Digital Ocean进行部署。
我安装了所有必要的东西,如pip、Python等,但我无法使python manage.py runserver
工作。
((g-v)是我的虚拟环境,所以不是问题。)
它会抛出以下错误:
(g-v) root@ubuntu-s-4vcpu-8gb-blr1-01:/home/g-v/src# python manage.py runserver
File "manage.py", line 14
) from exc
^
SyntaxError: invalid syntax
我读了一些帖子,推荐尝试python3 manage.py runserver
,但是当我尝试时,出现了以下错误:
(g-v) root@ubuntu-s-4vcpu-8gb-blr1-01:/home/g-v/src# python3 manage.py runserver
-bash: /home/g-v/bin/python3: cannot execute binary file: Exec format error
我的 pip list
命令输出结果如下:
(g-v) root@ubuntu-s-4vcpu-8gb-blr1-01:/home/g-v/src# pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Package Version
----------------------------- ----------
astroid 1.6.6
autopep8 1.4.4
backports.functools-lru-cache 1.5
certifi 2019.6.16
configparser 3.7.4
Django 1.11.23
enum34 1.1.6
futures 3.2.0
isort 4.3.21
lazy-object-proxy 1.4.1
mccabe 0.6.1
pip 19.2.2
pipenv 2018.11.26
pkg-resources 0.0.0
pycodestyle 2.5.0
Pygments 2.4.2
pylint 1.9.4
pytz 2019.2
setuptools 41.1.0
singledispatch 3.4.0.3
six 1.12.0
typing 3.7.4
virtualenv 16.7.3
virtualenv-clone 0.5.3
wheel 0.33.6
wrapt 1.11.2
python3
二进制文件似乎有问题。 - Willem Van Onsempython3 manage.py runserver
,无需执行source bin/activate
。 - Raj