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

For Python 3

python3 -m virtualenv venv

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


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.


As mentioned in the comments, you've got the virtualenv module installed properly in the expected environment since python -m venv allows you to create virtualenv's.

The fact that virtualenv is not a recognized command is a result of the virtualenv.py not being in your system PATH and/or not being executable. The root cause could be outdated distutils or setuptools.

You should attempt to locate the virtualenv.py file, ensure it is executable (chmod +x) and that its location is in your system PATH. On my system, virtualenv.py is in the ../Pythonx.x/Scripts folder, but this may be different for you.