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!
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
- go to project directory ( in which the virtual environment directory exist)
- In Ubuntu Linux user type following command:
source yourenvironmentname/bin/activate
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
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
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
.bat
file from your Virtual Environment
once it successfully created, If it is not finding then Copy the path where the .bat is in Virtual Environment
than paste it in VS Code terminal
like path\to\activate.bat –
Vichy open command prompt and follow these steps:-
1.cd C:\Users\user\Desktop\UserDjangoProject> pip install virtualenv 2.For Create a venv run this virtualenv -p python3 venv 3.Activate virtualenv venv\Scripts\activate 4.It will look like this (venv) C:\Users\user\Desktop\UserDjangoProject>
Run the django project run this./manage.py runserver
- use "cd ..\" to go back to the desired parent folder.
- Delete the initial venv folder in your parent folder where the venv exist.
- recreate the virtual environment with the name desired. The error actually means you are in a wrong folder Now, the pyvenv.cfg appears with the venv directory.
- execute the ".\Scritpts\activate" to activate. The command executed will go into the scripts folder in the venv folder to look for the activate.bat file (it's optional to append the .bat extension)
After creating the environment in django on windows os, to run at anytime, first of all make sure you know the correct already created environment name and start the tasks below:
- make sure to go in the specific directory where your project belong in command prompt
- then, type this command, WORKON (environment name)
Suppose your created environment is omsai, then type: workon omsai Thank you, this might help you
- open cmd in the virtual environment parent folder
- type
venv_folder_name\Scripts\activate
- hit enter
In linux the command is
source myenv/bin/activate
here myenv is considered to be in the current directory
Now it works,
api\project_name>.\venv\Scripts\activate
(venv) C:\PATH\api\covid_analysis_api>
by this way, it is neccesary to use cmd in windows rather than Powershell or Git bash.
in adition, I highly recommend to use .\venv\Scripts\activate
as this web page indicate
© 2022 - 2024 — McMap. All rights reserved.