Python could not import the module virtualenvwrapper.hook_loader?
Asked Answered
K

4

18

If Python could not import the module virtualenvwrapper.hook_loader, and I get this message

check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is
set properly.

How do I start to set it up in Debian 9?

Kwon answered 7/7, 2017 at 11:50 Comment(3)
How did you start? I.e., how did you install virtualenvwrapper?Parenthesis
all dependencies with virtualenwrapper is installed with pip.Kwon
pip, not pip3? pip is for Python 2.7, but you error shows python3.Parenthesis
P
23

You have to install virtualenvwrapper separately for different versions of Python:

pip install virtualenvwrapper
pip3 install virtualenvwrapper

The first one is for Python 2.7, the second for Python 3.

Parenthesis answered 7/7, 2017 at 12:3 Comment(3)
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory, but solved original error in question.Kwon
That's strange. pip install should install both the module and shell scripts. Did both pip install finish successfully?Parenthesis
I uninstalled for pip and installed successfully for python 3.Kwon
I
32

Installing virtualenv by both, pip and pip3 doesn't make any sense because installing it by any one shows virutalenvwrapper in both, pip list and pip3 list.

The right way is to copy the following code in your ~/.bashrc.

VIRTUALENVWRAPPER_PYTHON=$(which python3)

NOTE: Use the python version you want to use, in my case it's python3.

Innovate answered 20/9, 2019 at 20:19 Comment(1)
running which python3 in my terminal and then using it as [which python3 path]/virtualenvwrapper.sh did the trick for me!Aedes
P
23

You have to install virtualenvwrapper separately for different versions of Python:

pip install virtualenvwrapper
pip3 install virtualenvwrapper

The first one is for Python 2.7, the second for Python 3.

Parenthesis answered 7/7, 2017 at 12:3 Comment(3)
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory, but solved original error in question.Kwon
That's strange. pip install should install both the module and shell scripts. Did both pip install finish successfully?Parenthesis
I uninstalled for pip and installed successfully for python 3.Kwon
C
1

you need to change VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 to VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 for MacOS

Chantalchantalle answered 23/2, 2022 at 15:47 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Substation
for me on Mac it's source /opt/homebrew/bin/python3/virtualenvwrapper.shAedes
D
0

This have solved my issue on macOS Monterey 2022:

Terminal

cd
nano .bashrc 

Code in file

export WORKON_HOME=~/.virtualenvs 
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 
source /usr/local/bin/virtualenvwrapper.sh

save it

CTRL + x
y
Duran answered 16/7, 2022 at 19:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.