'virtualenv' is not recognized as an internal or external command, operable program or batch file
Question:
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:UsersgshivDesktopDjangoProject>virtualenv
'virtualenv' is not recognized as an internal or external command,
operable program or batch file.
Answers:
steps:
– go to where you want create django app on that folder.
then run this command on command prompt : python -m virtualenv .
(eg. C:UsersgshivDesktopdjango>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) .
- after running this command: run
.scriptsactivate
now you can see this type of line on cmd-prompt (django) C:UsersgshivDesktopdjango>
- i.e main folder name before the source path. now you can install any modules for your project that belongs to that main folder only.
pip install django works fine.
There are three points that you need to consider:
- Make sure that in the windows PATH variable there is an entry with your python installation and the scripts subfolder eg:
C:Program Files (x86)Python36-32
and C:Program Files (x86)Python36-32Scripts
- When using
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.
- 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.
When I ran the pip install virtualenv
command I got:
Requirement already satisfied: virtualenv in c:directorytoappdataroamingpythonpython36site-packages
so I tried forcing upgrade:
pip install --upgrade --force virtualenv
py -3 -m venv venv
try using the above command.
virtualenv venv
will work on only older version of python
Try executing virtualenv.exe
from its absolute path, like in my case i found it in C:Users<your user>AppDataRoamingPythonPython37Scriptsvirtualenv.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:somedirdir2dir3ML_1mlenvScriptspython.exe
Installing setuptools, pip, wheel…
done.
To install to a specific folder e.g E:publish
pip install virtualenv
virtualenv
.
Run pip uninstall virtualenv
and then pip install virtualenv
Run CMD as administrator and then enter
pip uninstall virtualenv
then re-run CMD as administrator and run
pip install virtualenv
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.
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
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
This almost works for all
- Open Command Prompt, navigate it to the Envs folder, run
"env_nameScriptsactivate"
- Check whether
virtualenv
is installed or not, if not install it:
pip install virtualenv
pip install virtualenvwrapper-win
- Game On. Check on your IDE.
- Open a cmd or ps with run as admin.
- Now run pip uninstall virtual.
- pip install virtual.
- Done 😀
Implementation:
- Go to the directory where you want to make a python env.
- type: virtualenv myEnv
- beep bop boop done.
ps: Always use cmd or powershell with run as admin if you’re installing some new package.
Use
python -m venv abc
Where abc is the name of the virtual environment
1)First Way as
python -m virtualenv name_of_virtual_environment
OR
2)Second Way as
py -3 -m venv name_of_virtual_environment
Use py -m virtualenv Your_Folder_Name
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.
Try to run
PowerShell.exe -command "./venv/Scripts/activate"
Windows
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
Basic Uses
Then, to create a virtual environment:
mkvirtualenv youVirtualEnvironmentName
- It will be activated automatically:
C:UsersYourUserName (youVirtualEnvironmentName) λ
First, to access an existing virtual environment:
C:UsersYourUserName λ workon youVirtualEnvironmentName
Next, to exit the currently active virtual environment:
C:UsersYourUserName (youVirtualEnvironmentName) λ deactivate
Finally, to list all your virtual environments:
C:UsersYourUserName λ lsvirtualenv
dir /b /ad 'C:UsersYourUserNameEnvs'
==================================================================
youVirtualEnvironmentName
I had this same issue using python3.
The solution was to use the python3 -m virtualenv .
command.
- Step 1: Run
pip uninstall virtualenv
.
- Step 2: Run
pip install virtualenv
.
- Step 2.1: Run
virtualenv
to check if it’s now working…
- Step 3: Still not working? Go to your prevouis console log to find where it says "WARNING: The script virtualenv.exe is installed in
‘C:UsersusernameAppDataRoamingPythonPython310Scripts’ which
is not on PATH."
- Step 4: Copy the specified path from the warning message.
- Step 5: Search for and open "System Properties" on your PC.
- Step 6: Click the Advance tab, and then the Environment Variables Button on the bottom right.
- Step 7: Click the variable value "Path" and then click edit.
- Step 8: In the Edit Environment variable window, click new then paste your path in any slot.
- Step 9: MAKE SURE you click OK twice and not to just exit out.
- Step 10: Reboot terminal and check again.
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:codepythontvenv>python -m venv myenv
E:codepythontvenv>cd myenvScripts
E:codepythontvenvmyenvScripts>activate.bat
(myenv) E:codepythontvenvmyenvScripts>deactivate.bat
E:codepythontvenvmyenvScripts>
Solution-2: py -3 -m venv name_of_virtual_environment
E:codepythontvenv>py -3 -m venv myenv
E:codepythontvenv>cd myenvScripts
E:codepythontvenvmyenvScripts>activate.bat
(myenv) E:codepythontvenvmyenvScripts>deactivate.bat
E:codepythontvenvmyenvScripts>
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:UsersgshivDesktopDjangoProject>virtualenv
'virtualenv' is not recognized as an internal or external command,
operable program or batch file.
steps:
– go to where you want create django app on that folder.
then run this command on command prompt : python -m virtualenv .
(eg. C:UsersgshivDesktopdjango>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) .
- after running this command: run
.scriptsactivate
now you can see this type of line on cmd-prompt(django) C:UsersgshivDesktopdjango>
- i.e main folder name before the source path. now you can install any modules for your project that belongs to that main folder only.
pip install django works fine.
There are three points that you need to consider:
- Make sure that in the windows PATH variable there is an entry with your python installation and the scripts subfolder eg:
C:Program Files (x86)Python36-32
andC:Program Files (x86)Python36-32Scripts
- When using
pip install virtualenv
, make sure that you runcmd
as administrator. Otherwise, there might an access denied error during installation and virtualenv will not be installed properly. - 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 willpip uninstall virtualenv
and install again.
When I ran the pip install virtualenv
command I got:
Requirement already satisfied: virtualenv in c:directorytoappdataroamingpythonpython36site-packages
so I tried forcing upgrade:
pip install --upgrade --force virtualenv
py -3 -m venv venv
try using the above command.
virtualenv venv
will work on only older version of python
Try executing virtualenv.exe
from its absolute path, like in my case i found it in C:Users<your user>AppDataRoamingPythonPython37Scriptsvirtualenv.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:somedirdir2dir3ML_1mlenvScriptspython.exe
Installing setuptools, pip, wheel…
done.
To install to a specific folder e.g E:publish
pip install virtualenv
virtualenv
.
Run pip uninstall virtualenv
and then pip install virtualenv
Run CMD as administrator and then enter
pip uninstall virtualenv
then re-run CMD as administrator and run
pip install virtualenv
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.
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
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
This almost works for all
- Open Command Prompt, navigate it to the Envs folder, run
"env_nameScriptsactivate"
- Check whether
virtualenv
is installed or not, if not install it:pip install virtualenv
pip install virtualenvwrapper-win
- Game On. Check on your IDE.
- Open a cmd or ps with run as admin.
- Now run pip uninstall virtual.
- pip install virtual.
- Done 😀
Implementation:
- Go to the directory where you want to make a python env.
- type: virtualenv myEnv
- beep bop boop done.
ps: Always use cmd or powershell with run as admin if you’re installing some new package.
Use
python -m venv abc
Where abc is the name of the virtual environment
1)First Way as
python -m virtualenv name_of_virtual_environment
OR
2)Second Way as
py -3 -m venv name_of_virtual_environment
Use py -m virtualenv Your_Folder_Name
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.
Try to run
PowerShell.exe -command "./venv/Scripts/activate"
Windows
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
Basic Uses
Then, to create a virtual environment:
mkvirtualenv youVirtualEnvironmentName
- It will be activated automatically:
C:UsersYourUserName (youVirtualEnvironmentName) λ
First, to access an existing virtual environment:
C:UsersYourUserName λ workon youVirtualEnvironmentName
Next, to exit the currently active virtual environment:
C:UsersYourUserName (youVirtualEnvironmentName) λ deactivate
Finally, to list all your virtual environments:
C:UsersYourUserName λ lsvirtualenv dir /b /ad 'C:UsersYourUserNameEnvs' ================================================================== youVirtualEnvironmentName
I had this same issue using python3.
The solution was to use the python3 -m virtualenv .
command.
- Step 1: Run
pip uninstall virtualenv
. - Step 2: Run
pip install virtualenv
. - Step 2.1: Run
virtualenv
to check if it’s now working… - Step 3: Still not working? Go to your prevouis console log to find where it says "WARNING: The script virtualenv.exe is installed in
‘C:UsersusernameAppDataRoamingPythonPython310Scripts’ which
is not on PATH." - Step 4: Copy the specified path from the warning message.
- Step 5: Search for and open "System Properties" on your PC.
- Step 6: Click the Advance tab, and then the Environment Variables Button on the bottom right.
- Step 7: Click the variable value "Path" and then click edit.
- Step 8: In the Edit Environment variable window, click new then paste your path in any slot.
- Step 9: MAKE SURE you click OK twice and not to just exit out.
- Step 10: Reboot terminal and check again.
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:codepythontvenv>python -m venv myenv
E:codepythontvenv>cd myenvScripts
E:codepythontvenvmyenvScripts>activate.bat
(myenv) E:codepythontvenvmyenvScripts>deactivate.bat
E:codepythontvenvmyenvScripts>
Solution-2: py -3 -m venv name_of_virtual_environment
E:codepythontvenv>py -3 -m venv myenv
E:codepythontvenv>cd myenvScripts
E:codepythontvenvmyenvScripts>activate.bat
(myenv) E:codepythontvenvmyenvScripts>deactivate.bat
E:codepythontvenvmyenvScripts>