Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "virtualenv : command not found" but install location is in PYTHONPATH

This has been driving me crazy for the past 2 days. I installed virtualenv on my Macbook using pip install virtualenv. But when I try to create a new virtualenv using virtualenv venv, I get the error saying "virtualenv : command not found".

I used pip show virtualenv and the location of the installation is "Location: /usr/local/lib/python2.7/site-packages" but I can't figure out where the executable is. I tried dozens other similar looking posts but those solutions do not work for me.

Any ideas what might be going wrong here?

like image 327
Pravesh Jain Avatar asked Oct 10 '16 18:10

Pravesh Jain


People also ask

How do I fix virtualenv is not recognized?

To Solve 'virtualenv' is not recognized as an internal or external command, operable program or batch file Error You just need to reinstall virtualenv.

How do I add a path to Pythonpath in virtualenv?

Just put a file with a . pth extension (any basename works) in your virtualenv's site-packages folder, e.g. lib\python2. 7\site-packages , with the absolute path to the directory containing your package as its only contents.

Where virtualenv is installed?

If you try to run virtualenv and find it isn't present, you can install it using pip. virtualenv.exe will likely now be found in your python installation directory under the Scripts subdirectory.

How do you check virtualenv is installed or not?

Verify if Virtualenv is installed There is a chance that virtualenv is already installed on your system. If you see a version number (in my case 1.6. 1), it's already installed.


2 Answers

The only workable approach I could figure out (with help from @Gator_Python was to do python -m virtualenv venv. This creates the virtual environment and works as expected.

I have custom python installed and maybe that's why the default approach doesn't work for me.

like image 85
Pravesh Jain Avatar answered Sep 21 '22 17:09

Pravesh Jain


On macOS Mojave
First check python is in the path.
python --version
Second check pip is installed.
pip --version
If it is not installed.
brew install pip
Third install virtualenv
sudo -H pip install virtualenv

like image 23
Mian Asbat Ahmad Avatar answered Sep 20 '22 17:09

Mian Asbat Ahmad