I created a virtual environment with python -m venv myenv
from the command prompt, but I don't know how to activate it. I tried executing activate.bat
from the command prompt but it does not activate.
In other words, I don't see the current path changed to (myenv) C:\Pathname...
to indicate that myenv has been activated. When I execute activate.bat
the venv is not activated.
This thread it old but I had the same problem today and found a working answer for it. I've been using python 3.6 venv for a few months now without issues but today I ran across a new error message:
C:\test>python -m venv vm
Error: Command '['C:\\test\\vm\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
I scoured Stack and other resources for an answer but didn't find anything specific to Windows 10. (AskUbunto had a solution that was specific to Linux). I did find breadcrumbs spread out across the InterWebs and pieced this together.
You need this python script: https://bootstrap.pypa.io/get-pip.py
Install your virtual environment as usual but without pip:
python -m venv virtual --without-pip
This method will create all of the necessary files including the activate bat files.
Copy the get-pip.py file into the virtual\Scripts subdirectory
cd into the Scripts subdirectory and "activate" python Note: the cmd line should name the directory from which python was activated:
(virtual) C:\test\virtual\Scripts>
(if it says (root), it's activated your core installation)
now execute the script
C:\test\virtual\Scripts>python get-pip.py
once run, I typed:
(virtual) C:\test\virtual\Scripts>pip freeze
to generate a freeze list and verify proper installation. It should return nothing, no error msg, no freeze list.
(virtual) C:\test\virtual\Scripts>pip freeze
click==6.7
Flask==0.12.2
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
Werkzeug==0.12.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With