简体   繁体   English

虚拟环境在Django中不起作用

[英]Virtual environment is not working in Django

I am deploying my Django app on digitalocean but I get an error after the giving the command in my terminal to migrate. 我在digitalocean上部署了Django应用,但是在终端中输入要迁移的命令后却出现了错误。 Help me to figure out the error so that I can fix. 帮助我找出错误,以便我修复。

terminal output 终端输出

urban@ubuntu-s-1vcpu-1gb-blr1-01:~$ source bin/activate
(urban) urban@ubuntu-s-1vcpu-1gb-blr1-01:~$ cd lok
(urban) urban@ubuntu-s-1vcpu-1gb-blr1-01:~/lok$ python manage.py migrate
File "manage.py", line 14
) from exc
     ^
SyntaxError: invalid syntax
(urban) urban@ubuntu-s-1vcpu-1gb-blr1-01:~/lok$ ls
business    List     manage.py  news       sports             
templates
db.sqlite3  lokswar  movie      README.md  static_my_project

Your version of Django requires Python 3, but it looks like python is python2 , even after activating the virtual environment. 你的Django的版本需要Python 3,但它看起来像pythonpython2 ,甚至激活虚拟环境之后。 You can use which python to check that python is pointing to the executable in your virtual environment. 您可以使用which python来检查python指向虚拟环境中的可执行文件。

If your virtual environment was created with python 2, then you'll have to create a new virtual environment that uses python 3. 如果您的虚拟环境是使用python 2创建的,则必须创建一个使用python 3 的新虚拟环境

deactivate
python3 -m venv /path/to/urban.new
source /path/to/urban.new/bin/activate
# install requirements

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM