I am using Python3.7 and following the virtualenv and virtualenvwrapper installation as mentioned on this FreeCodeCamp article.
The changes to my .bashrc file look as follows:
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # popo edit: Add Python alias alias python=python3 # popo edit: Step to activate virtualenvs export WORKON_HOME=$HOME/.virtualenvs # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac # SOme more things.... #Virtualenvwrapper settings: export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_VIRTUALENV=/home/pra-dan/.local/bin/virtualenv source /usr/local/bin/virtualenvwrapper.sh On sourcing the .bashrc, I get
/usr/bin/python3: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper') virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is set properly. ALthough, I managed to make an environment (idk how) and on typing workon, I get its name.
But now when I wish to make a new environment, I enter $ mkvirtualenv wrk -p python3, I get
ERROR: virtualenvwrapper could not find /home/pra-dan/.local/bin/virtualenv in your path 3 Answers
I think you missed an important note in the instructions: the export lines need to come before sourcing virtualenvwrapper.sh. You're sourcing virtualenvwrapper.sh twice.
3Confirm that the python path provided in
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 is same as the python path where you installed virtualenv and virtualenvwrapper.
To find your python path, use which python or, which python3 command in console.
Also verify that either python or python3 command in terminal triggers a python IDLE of the desired version.
On Ubuntu 18.04, I have had the following:
usr/bin/python3: Error while finding module specification for virtualenvwrapper.hook_loader'` (ModuleNotFoundError: No module named virtualenvwrapper`) virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is set properly.
sudo gedit .bashrc It is how virtualenvwrapper settings in .bashrc look like in my case:
export WORKON_HOME=~/.envs export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source ~/.local/bin/virtualenvwrapper.sh And I have done the following:
sudo apt install python3-pip sudo pip3 install virtualenv virtualenvwrapper source ~/.bashrc That has helped me.