6

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!

RoosyDepp
  • 193
  • 2
  • 2
  • 8
  • 2
    Possible duplicate of [Python virtualenv questions](https://stackoverflow.com/questions/4527958/python-virtualenv-questions) – thom747 Mar 13 '19 at 13:19

11 Answers11

23

In windows: Press Windows (or Windows+R) and then type “cmd”: Run the Command Prompt in normal mode.

  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>
  5. Then run pip install -r requirements.txt
  6. Run the django project run this./manage.py runserver
Shariful Islam
  • 526
  • 3
  • 10
2

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
Somnath Muluk
  • 55,015
  • 38
  • 216
  • 226
2
  1. go to project directory ( in which the virtual environment directory exist)
  2. In Ubuntu Linux user type following command: source yourenvironmentname/bin/activate
Neuron
  • 5,141
  • 5
  • 38
  • 59
0

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 
caiolopes
  • 561
  • 8
  • 14
0

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

Rvector
  • 2,312
  • 1
  • 8
  • 17
  • I just wanted to know, how to activate the .bat file from VS CODE! Please do let me know! – RoosyDepp Mar 13 '19 at 16:18
  • @RoosyDepp, It will automatically find the `.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** – Lars Aug 31 '21 at 11:32
0

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

0
  1. use "cd ..\" to go back to the desired parent folder.
  2. Delete the initial venv folder in your parent folder where the venv exist.
  3. 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.
  4. 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)
0

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:

  1. make sure to go in the specific directory where your project belong in command prompt
  2. then, type this command, WORKON (environment name)

Suppose your created environment is omsai, then type: workon omsai Thank you, this might help you

nedam Kailash
  • 165
  • 1
  • 9
0
  • open cmd in the virtual environment parent folder
  • type venv_folder_name\Scripts\activate
  • hit enter
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
0

In linux the command is

source myenv/bin/activate

here myenv is considered to be in the current directory

Ruchi
  • 55
  • 5
-1

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

https://mothergeo-py.readthedocs.io/en/latest/development/how-to/venv-win.html#activate-the-environment