ERROR: virtualenvwrapper could not find virtualenv in your path

50,234

Solution 1

I finally found out what the problem was :

virtualenvwrapper.sh is written in BASH and not in Python. So virtualenv is called from a shell (zsh). I didn't have to bother about my PYTHONPATH, but about my PATH (I was already able to import virtualenv from my python shell anyway).

I just added the correct directory to my PATH and everything worked fine (the directory containing the virtualenv executable, i-e /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages which isn't included in my PATH by default despite being the directory virtualenv and other pip-installed tools was in).

Solution 2

Re-installling virtualenv fixed my problem.

I had the same issue.

$ mkvirtualenv mysite
ERROR: virtualenvwrapper could not find virtualenv in your path

After a lot of time consuming efforts, I decided to re-install virtualenv.

sudo apt install virtualenv

This fixed my issues. I already had virtualenv installed. But I think it got broken or met with some errors.

Solution 3

I am using python3 with virtualenvwrapper installed on Ubuntu 18.04, using pip3 without sudo. If you are in this situation, you might find interesting my configuration.

In the end of my .bashrc I added the following rows (remember to put your username in the YOUR_USERNAME field):

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/YOUR_USERNAME/.local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh

Then restart the cli with ctrl-D ctrl-T or reload the config with source ~/.bashrc. Then you should be good to go! Try the installation with:

lsvirtualenv
mkvirtualenv test
workon test
deactivate
rmvirtualenv test

If you could create and delete a virtual environment, you are ready to go.

Solution 4

  1. sudo find / -name "virtualenv"

    Then I find the executable file path is:

    /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/virtualenv

  2. Touch a soft link in the /usr/local/bin/ directory or add the path to .bash_profile, I prefer the former:

    sudo ln -s /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/virtualenv /usr/local/bin/virtualenv
    

Solution 5

  1. Find where is your virtualenvwrapper located. in my case
 ~/.local/bin

May be it's installed in

/usr/local/bin/

It totally depends on the System or Package Manager you are using.

  1. Add this path in your shell configuration .bashrc or .zshrc or whatever by simply
PATH=$PATH:<directory_you_want_to_add>

for example

PATH=$PATH:~/.local/bin

Also add the following configuration in .bashrc or .zshrc

# the path you want your virtual environments to be saved and loaded from
export WORKON_HOME=$HOME/.virtualenvs 
export PROJECT_HOME=$HOME/<project_folder>

# most important, this is the program which loads virtualenv
# please update the path where virtualenvwrapper.sh is located
source /usr/local/bin/virtualenvwrapper.sh 

Don't Forget to restart the shell.. or reload the configuration...

To test whether it worked

mkvirtualenv test

if you see a test environment created then everything is ok.

For Detailed Installation Instructions go to the docs: virtualenvwrapper installation

Share:
50,234
vmonteco
Author by

vmonteco

Happy programmer!

Updated on July 22, 2021

Comments

  • vmonteco
    vmonteco almost 3 years

    I'm trying to create a virtualenv with virtualenvwrapper, but when I use mkvirtualenv I get the following :

    ERROR: virtualenvwrapper could not find virtualenv in your path
    

    I assumed it was a PYTHONPATH problem. But if I do a pip show virtualenv I get the following :

    ---
    Metadata-Version: 2.0
    Name: virtualenv
    Version: 13.1.0
    Summary: Virtual Python Environment builder
    Home-page: https://virtualenv.pypa.io/
    Author: Jannis Leidel, Carl Meyer and Brian Rosner
    Author-email: [email protected]
    License: MIT
    Location: /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages
    Requires:
    

    And here is my PYTHONPATH :

    /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/bin:/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/bin:/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages:/Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages:~/.brew/Cellar

    It contains the directory containing virtualenv!

    (i-e : /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages )

    My ~/.zshrc contains :

    export WORKON_HOME=~/Envs
    export PROJECT_HOME=$HOME/Devel
    source $HOME"/Library/Python/2.7/bin/virtualenvwrapper.sh"
    

    EDIT : virtualenvwrapper.sh is written in bash, perhaps should I check my PATH instead of my PYTHONPATH ?

    So, what could the problem be? How could I fix it?

    Thank you in advance for your help.