'virtualenv and virtualenvwrapper "There was a p roblem running the initialization hooks" all of a sudden

So my development environment really hasn't changed for a long time. I am using Bash on Ubuntu on Windows for about a year now. I just apply the regular updates with:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Haven't had any issues until last week. When I would workon env and then start up Django, all of these Python errors related to encryption and hashing would come up. Don't really remember what they said, but apparently couldn't find something. I just ignored them because I am in the middle of a project and figured I'd address them later since it is just the dev server.

Anyway, I come in yesterday to work and all of a sudden I am getting:

-bash: /usr/local/bin/python3.6: No such file or directory
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/local/bin/python3.6 and that PATH is
set properly.

I read a number of SO questions related to this. Basically they all suggested to uninstall virtualenv, virtualenvwrapper, and pip. That is if doing pip3 install --upgrade virtualenvwrapper didn't work, which it didn't. Uninstalled, reinstalled, and left work yesterday with everything seeming to be running fine.

Came into work today and the problem is back so I am not sure how to fix it. I am running Python 3.6.3 and PIP3. My ~/.bashrc has the following with some additional lines that I have added to "fix" the issue:

export PYTHONPATH=${PYTHONPATH}:/usr/bin
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6
export WORKON_HOME=/mnt/c/dev/.venvs
export VIRTUALENVWRAPPER_VIRUTALENV_ARGS='--no-site-packages'
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
source /usr/local/bin/virtualenvwrapper.sh

The latest error message is:

/usr/bin/python3.6: 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.6 and that PATH is
set properly.
-bash: /usr/local/bin/python3.6: No such file or directory
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/local/bin/python3.6 and that PATH is
set properly.

Python 3.6.3 is in the /usr/bin and virtualenvwrapper.sh is in the /usr/local/bin/virtualenvwrapper.sh. Not sure why it is looking in /usr/local/bin/python3.6 as I don't see where this is specified.

Wish I knew what caused it to break all of a sudden. Thanks for the help!



Solution 1:[1]

I know this is a really old question, but I managed to remove all those errors by adding

export VIRTUALENVWRAPPER_PYTHON=$(which python3)

to .bashrc

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MikePearce