[英]Python3 commmands not working in my virtual environment
I have Python-3.8.1 installed in my virtual environment, but still the default version is Python-2.7 only (because of MacOS)我在我的虚拟环境中安装了 Python-3.8.1,但默认版本仍然是 Python-2.7 (因为 MacOS)
Now, whenever I try to run a command starting with python3
, such as python3 manage.py startapp...
or python3 manage.py runserver
, I get this error:现在,每当我尝试运行以
python3
开头的命令时,例如python3 manage.py startapp...
或python3 manage.py runserver
,我都会收到此错误:
SyntaxError: Generator expression must be parenthesized
Are you using an older version of Django?您使用的是旧版本的 Django 吗? Based on this Django 1.11 and Python 3.7+ are incompatible.
基于此Django 1.11 和 Python 3.7+ 不兼容。
To upgrade your django package, first switch to your virtual environment:要升级您的 django package,首先切换到您的虚拟环境:
conda activate your-django-env-name
Then run the following command to get the latest version on your virtual environment:然后运行以下命令以获取虚拟环境的最新版本:
pip install django --upgrade
conda create -n myenv python=3.6
conda create -n myenv django=1.11.29
For your use case I suggest:对于您的用例,我建议:
conda create -n myDjangoEnv python=3.6 django=1.11.29
First activate the conda environment before running any commmand:在运行任何命令之前首先激活 conda 环境:
conda activate myDjangoEnv
You won't be required to type 'python3', simply use 'python'.您不需要输入“python3”,只需使用“python”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.