问题
I am currently on Windows and the Venv is not getting activatedUnactivated ENV, Is there any way to fix this. Thanking you guys in advance! Help out a newbie!
回答1:
In windows: Press Windows (or Windows+R) and then type “cmd”: Run the Command Prompt in normal mode.
cd C:\Users\user\Desktop\UserDjangoProject> pip install virtualenv
- For Create a venv run this
virtualenv -p python3 venv
- Activate virtualenv
venv\Scripts\activate
- It will look like this
(venv) C:\Users\user\Desktop\UserDjangoProject>
- Then run
pip install -r requirements.txt
- Run the django project run this
./manage.py runserver
回答2:
I think you are calling the activate.bat script like a Unix environment, using:
./venv/Scripts/activate.bat
While in Windows you should call like this:
\venv\Scripts\activate.bat
回答3:
To make easy here with visual studio code You have to create a venv at the root of your django project. If you have a project my_project then in the folder my_project you must have one (v) env in it. Thus visual studio code will be able to detect the environment. And so you'll be able to change the environment (python version) in the bottom left in visual studio code
example of project
├── book
├── db.sqlite3
├── env
├── manage.py
├── static
├── templates
└── tuto_signal
here the project name is tuto_signal and the env is at the same level of manage.py, book is an app created by ./manage.py startapp book.
Try to do like this an let me know the result.
Hope it can help you
回答4:
In Linux/Mac, go to the project folder (in which, there should be env folder created).
. my_env_name/bin/activate
In Windows, go to the project folder (in which, there should be env folder created).
my_env_name\Scripts\activate
来源:https://stackoverflow.com/questions/55142774/how-to-activate-virtual-environment-in-django