ERROR: virtualenvwrapper could not find virtualenv in your path
Asked Answered
D

14

63

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.

Debunk answered 7/7, 2015 at 16:44 Comment(5)
Show your .bashrc fileIsometropia
@AjayGupta Do you mean my ~/.zshrc? There are several things in it and won't show everything, what should the parts I'll show be related to?Debunk
Its the .bashrc file in both mac and linux, which OS are you on?Isometropia
@AjayGupta I know but it is the .bashrc if I use bash, but I don't : I use zsh instead.Debunk
Please see this answer https://mcmap.net/q/303409/-can-39-t-find-virtualenv-in-path-even-though-its-thereDebris
D
17

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).

Debunk answered 7/7, 2015 at 18:41 Comment(2)
Directory of what exactly? I am sorry I am very much exhausted. My path to virtualenv and wrapper is /usr/local/bin. However I installed my Pyhtton3 with HomeBrew. I don't know if messes up my shell.Debris
@OzkanSerttas Hello, it's a bit old but if I remember correctly, it was about adding the path of the directory containing the virtualenv executable. I edited my answer for further clarification.Debunk
D
68

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.

Decumbent answered 6/10, 2016 at 13:26 Comment(5)
For me, I had to do sudo apt install --reinstall virtualenv. Thanks for the suggestion!Epigraphy
sudo apt install virtualenv --upgrade fixed it for meFrisky
Neither fixed it for me. sudo apt install virtualenv --upgrade gives error ERROR: virtualenvwrapper could not find virtualenv in your pathTrondheim
@Trondheim I think --upgrade works only if the package is already installed.Decumbent
This did not fix my issue, it made things worse. This is not a good solution as the problem maybe deeper for others. People maybe mixing up their pip installs and apt installs which are different paths. The solution is to fix your path problems.Kumler
F
48

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.

Fernery answered 12/9, 2018 at 18:9 Comment(4)
This was the easiest solution for fixing this issue on Windows 10 Ubuntu subsystem, thanks!Joshua
Worked on my Windows 10 Ubuntu subsystem too. The critical part was export VIRTUALENVWRAPPER_VIRTUALENV=/home/YOUR_USERNAME/.local/bin/virtualenv. I searched for the virtualenv using Everything (a search program) and found that it exists is some long directory with /.local/bin/virtualenv at the end.Torras
export VIRTUALENVWRAPPER_VIRTUALENV was also the line that got it working for me. ElementaryOS 6, python 3.8. The virtualenvwrapper installation instructions do not include this stepStarkey
This should be marked as the right solution.Unhallow
I
24
  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
    
Irizarry answered 3/7, 2016 at 8:21 Comment(2)
This was the best option for me, since my pip installations in vagrant are located in an unsual place (/home/vagrant/.local/bin/virtualenv).Parted
Yes, indeed. This is the best piece of advice I've got so far about virtualenvwrapper cannot find virtualenv. Thank you!Emogene
D
17

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).

Debunk answered 7/7, 2015 at 18:41 Comment(2)
Directory of what exactly? I am sorry I am very much exhausted. My path to virtualenv and wrapper is /usr/local/bin. However I installed my Pyhtton3 with HomeBrew. I don't know if messes up my shell.Debris
@OzkanSerttas Hello, it's a bit old but if I remember correctly, it was about adding the path of the directory containing the virtualenv executable. I edited my answer for further clarification.Debunk
B
9
  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

Boehmenism answered 22/12, 2017 at 9:54 Comment(0)
A
7

For me it was:

export PYTHONPATH=/usr/bin/python3
export PATH=$HOME/.local/bin:$PATH
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh

I changed the line to:

export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv

It worked.

Agapanthus answered 31/7, 2020 at 16:32 Comment(0)
F
4
ERROR: virtualenvwrapper could not find virtualenv in your path

This error means - program virtualenv is not in your system path. This mostly happens if you install virtualenv via pip without sudo. This kind of installation stores data in users local directory e.g ~/.local/bin. So first step is to find where this binary present. You can do that using locate program. First update its database using sudo updatedb. Then run locate *bin/virtualenv. Whatever path you get, append it in system path variable. This you can do by adding below line in your shell config file e.g. ~/.bashrc or ~/.zshenv.

export PATH=$PATH:/your/path

e.g.

export PATH=$PATH:~/.local/bin

Now open new shell and try again. Error should be gone.

Frigid answered 25/8, 2019 at 15:56 Comment(0)
F
4

In my case, I tested use this command:

 sudo find / -name "virtualenv"

and I have a list with all path to this file,

I tested one to one and solved with path:

export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv

My configurations to environment variables is :

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

in file .bashrc. Now all its works.

Fissi answered 10/8, 2020 at 16:9 Comment(0)
L
2

The way I did it was (using zsh) in this way:

export PATH=$HOME/bin:/usr/local/bin:$PATH:/Users/username/Library/Python/2.7/bin:$PATH

I simply located the file of virtualenvwrapper.sh inside this path /Users/username/Library/Python/2.7/bin:$PATH

and added that path to PATH.

Libra answered 27/8, 2018 at 1:7 Comment(0)
P
2

I have set the variable VIRTUALENVWRAPPER_VIRTUALENV in my .zshrc to the full path of the virtualenv binary and it works for me.

Here is my .zshrc file:

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/Library/Python/2.7/bin/virtualenv
source $HOME/Library/Python/2.7/bin/virtualenvwrapper.sh
Pembroke answered 28/11, 2020 at 19:46 Comment(0)
D
1

Your PYTHONPATH makes me think you have Homebrew installed. It sounds like virtualenvwrapper was installed with either your system pip or your homebrew pip while it is being executed with the opposite python interpreter.

Deposition answered 7/7, 2015 at 16:51 Comment(6)
That's right, homebrew is installed. It seems like it is installed with both, could it cause a problem? I though that the interpreter crawls my PYTHONPATH and use the first virtualenv he finds.Debunk
I don't use virtualenvwrapper but it seems the virtualenvwrapper.sh script that is sourced determines which python interpreter to use before exporting the wrapper functions to your current environment.Deposition
You mean the virtualenvwrapper.sh ?Debunk
I did, sorry. I clarified the above comment.Deposition
Ah, this script's purpose is to define some functions in bash, such as "workon". You have its source here : bitbucket.org/dhellmann/virtualenvwrapper/src/…Debunk
Ah, therefore, perhaps should I search in my PATH and not in my PYTHONPATH if virtualenvwrapper isn't written in python but in BASH...? I'll check this.Debunk
C
1

I had this same issues and tried many many things, what found as a solution is i had three pip version, pip with 2.7, 3.6 and 3.7. and 3.6 was the one works fine for many things, and install as sudo pip3.6 install virtualenv, and it works fine. I would suggest, check your pip version and tried to install based on your pip ver.

Cheung answered 17/2, 2019 at 23:23 Comment(0)
I
0

Removing all virtualenv related packages would work.

pip freeze -l | grep ^virtualenv | awk -F= '{print $1}' | xargs pip uninstall -y
Iconium answered 21/7, 2021 at 10:10 Comment(0)
O
0

I'm on Windows and I had the exact same problem. I had the VIRTUALENVWRAPPER_VIRTUALENV environment variable in my .bashrc pointing to virtualenv, but I kept getting an error. Apparently, I was pointing to the virtualenv/ folder, instead of the virtualenv.exe executable file (which was in another location). Once I corrected it, everything worked for me.

Otic answered 12/12, 2023 at 21:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.