Reputation: 5474
After I installed Python and Djangom, I'm trying to use virtualenv
for django project purpose using virtualenv. I installed virtualenv using pip.
pip install virtualenv # got install successfully
When I tried to run it, I got the error message
C:\Users\gshiv\Desktop\DjangoProject>virtualenv
'virtualenv' is not recognized as an internal or external command,
operable program or batch file.
Upvotes: 111
Views: 287701
Reputation: 1793
pip install virtualenv
open cmd in your desired project folder
python -m venv .venv
cd .venv
cd Scripts
activate
cd ..
cd ..
That worked for me, hope this helps.
Upvotes: 1
Reputation: 171
In my cases, the problem is that I had install virtualenv
using a normal user.
Switch to Admin or Administrator (if using Windows OS), then run
pip uninstall virtualenv
and
pip install virtualenv
Close the Admin or Administrator terminal and open the terminal with your normal user and run
virtualenv myenv
It should create the python virtual environment successfully.
Upvotes: 1
Reputation: 143
Below command worked for me:
python -m virtualenv virtualenvname
However, after creating a virtual environment, I could not install any package into it and was getting error: "ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv."
To resolve that, I have had to update the pyvenv.cfg file from the virtual environment folder as below:
include-system-site-packages = true
Reference: https://github.com/microsoft/vscode-python/issues/14327
Update
I ran into all sorts of issues like not able to run django-admin command. I have installed python 3.10 from windows store as running python command was taking me to windows store. I already had python 3.11 hence I uninstalled 3.10 and then:
I have found that the path for my python installation was not added into my environment variables (PATH).
Upvotes: 0
Reputation: 773
If you can not find your virtualenv
command in the windows console/terminal after installing it with pip
, try this to make your environment 馃斀
python -m virtualenv <nameOfEnv>
If you want to use a specific version of python, initialize it like this 馃斀
python -m virtualenv <nameOfEnv> -p=<C:/path/to/python/version3.x.x/python.exe>
When using windows for first installation, you can use python from WindowsApp
Upvotes: 57
Reputation: 308
You just need to reinstall virtualenv. First of all you need to uninstall virtualenv with this command.
pip uninstall virtualenv
Then just reinstall with this command.
pip install virtualenv
Solution-1: python -m venv name_of_virtual_environment
E:\code\python\tvenv>python -m venv myenv
E:\code\python\tvenv>cd myenv\Scripts\
E:\code\python\tvenv\myenv\Scripts>activate.bat
(myenv) E:\code\python\tvenv\myenv\Scripts>deactivate.bat
E:\code\python\tvenv\myenv\Scripts>
Solution-2: py -3 -m venv name_of_virtual_environment
E:\code\python\tvenv>py -3 -m venv myenv
E:\code\python\tvenv>cd myenv\Scripts
E:\code\python\tvenv\myenv\Scripts>activate.bat
(myenv) E:\code\python\tvenv\myenv\Scripts>deactivate.bat
E:\code\python\tvenv\myenv\Scripts>
Upvotes: 3
Reputation: 173
pip uninstall virtualenv
.pip install virtualenv
.virtualenv
to check if it's now working...Upvotes: 3
Reputation: 43
I had this same issue using python3.
The solution was to use the python3 -m virtualenv .
command.
Upvotes: 1
Reputation: 807
If you want to use the lsvirtualenv
command with virtualenv
, follow the steps below.
Incorrect:
python -m pip install virtualenv
python -m pip install virtualenvwrapper
Correct:
python -m pip install virtualenv
python -m pip install virtualenvwrapper-win
Then, to create a virtual environment:
mkvirtualenv youVirtualEnvironmentName
C:\Users\YourUserName (youVirtualEnvironmentName) 位
First, to access an existing virtual environment:
C:\Users\YourUserName 位 workon youVirtualEnvironmentName
Next, to exit the currently active virtual environment:
C:\Users\YourUserName (youVirtualEnvironmentName) 位 deactivate
Finally, to list all your virtual environments:
C:\Users\YourUserName 位 lsvirtualenv dir /b /ad 'C:\Users\YourUserName\Envs' ================================================================== youVirtualEnvironmentName
Upvotes: 1
Reputation: 1
I got this error too but I figure it out.
you just have to open PowerShell as administrator and then write following command Set-ExecutionPolicy unrestricted
then type A
. you are all set!
now uninstall the packages and re-install them.
Now if you write flask --version
or virtualenv --version
There will be no error at all.
Upvotes: 0
Reputation: 1
1)First Way as
python -m virtualenv name_of_virtual_environment
OR
2)Second Way as
py -3 -m venv name_of_virtual_environment
Upvotes: -1
Reputation: 432
Use
python -m venv abc
Where abc is the name of the virtual environment
Upvotes: 15
Reputation: 67
Implementation:
ps: Always use cmd or powershell with run as admin if you're installing some new package.
Upvotes: -2
Reputation: 3
Try executing virtualenv.exe
from its absolute path, like in my case i found it in C:\Users\<your user>\AppData\Roaming\Python\Python37\Scripts\virtualenv.exe
.
I tried this and it worked, here refer the logs as follows:
Using base prefix c:\\users\\<user>\\appdata\\local\\programs\\python\\python37-32
New python executable in C:\somedir\dir2\dir3\ML_1\ml\env\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
Upvotes: 0
Reputation: 1
Make sure that virtualenv
has been installed correctly. Check in the python scripts subfolder - there must exist an .exe
named virtualenv.exe
. If not, uninstall will pip uninstall virtualenv
and install again.
Upvotes: -1
Reputation: 670
To install to a specific folder e.g E:\publish
pip install virtualenv
virtualenv
.
Upvotes: 3
Reputation: 97
This almost works for all
"env_name\Scripts\activate"
virtualenv
is installed or not, if not install it:
pip install virtualenv
pip install virtualenvwrapper-win
Upvotes: 0
Reputation: 367
Run CMD as administrator and then enter
pip uninstall virtualenv
then re-run CMD as administrator and run
pip install virtualenv
Upvotes: 10
Reputation: 11
For windows
First, install -> pip install virtualenvwrapper-win
Then setup -> mkvirtualenv myproject
Then you see the list of virtual environment
To see it you write-> lsvirtualenv
For working this environment we write -> workon myproject
Upvotes: 1
Reputation: 171
py -3 -m venv venv
try using the above command.
virtualenv venv
will work on only older version of python
Upvotes: 15
Reputation: 3711
When I ran the pip install virtualenv
command I got:
Requirement already satisfied: virtualenv in c:\directory\to\appdata\roaming\python\python36\site-packages
so I tried forcing upgrade:
pip install --upgrade --force virtualenv
Upvotes: 19
Reputation: 5474
steps: - go to where you want create django app on that folder.
then run this command on command prompt : python -m virtualenv .
(eg. C:\Users\gshiv\Desktop\django>python -m virtualenv .)
where django is the my folder i want run virtualenv and .(dot) indicates virtualenv install all it's folder in django folder otherwise you can use other folder name instead .(dot) this time virtulenv creates a folder in main folder(django) .
.\scripts\activate
now you can see this type of line on cmd-prompt (django) C:\Users\gshiv\Desktop\django>
pip install django works fine.
Upvotes: 136
Reputation: 608
There are three points that you need to consider:
C:\Program Files (x86)\Python36-32\
and C:\Program Files (x86)\Python36-32\Scripts\
pip install virtualenv
, make sure that you run cmd
as administrator. Otherwise, there might an access denied error during installation and virtualenv will not be installed properly.virtualenv.exe
. If not, uninstall will pip uninstall virtualenv
and install again.Upvotes: 25