Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating Python Virtual Environment on Windows 11

I am trying to create a venv virtual enviroment for Python in Window's command prompt. I created the enviroment; however, I am having difficulties using it because when I run the "activate" command it is not working. I think the problem is related to that the virtual enviroment does not have a scripts file like other window machines do, but rahter a bin file which has the activate script. When I run the activate command with the bin in the file directory I still get an error.

enter image description here

I have been trying to solve the problem for the past 4-5 hours and am completely stuck. I tried destroying and reconstructing the virtual enviroment, I tried using different extensions (.bat, .exe, .ps1, and just \activate), and tried using powershell.

Please let me know if you have any ideas what I am doing wrong!

like image 450
Michael Napoli Avatar asked Mar 06 '26 05:03

Michael Napoli


1 Answers

Open a command prompt terminal by either searching command prompt in the Windows search bar, or press the Windows Key + R and enter cmd.

Create the virtual environment in a desired directory using the following command:

python -m venv env

This will create a new folder called env inside the directory where you executed the command.

You can activate the created virtual environment by running the following command in the same directory where you executed the last command:

cd env/Scripts && activate && cd ../../

I hope this helps.

like image 100
Mehrdad Moradi Avatar answered Mar 07 '26 23:03

Mehrdad Moradi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!