7

when logging into my VPS with ssh keys, I get this:

Command '' not found, but can be installed with:

sudo apt install libpam-mount      
...           
sudo apt install nmh               

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= and that PATH is
set properly.

Here's my .bashrc variables:

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

What I've tried

  • Sourcing .bashrc, ~/.profile and /usr/local/bin/virtualenvwrapper.sh (no errors)
  • Upgrading virtualenvwrapper with pip3 --upgrade (latest)

Also, my virtualenv's work perfectly.

W. Reyna
  • 171
  • 1
  • 4
  • Try adding `set -x` to your .bashrc just before you source virtualenvwrapper.sh, that might give you a hint of what might be going wrong... – filbranden Feb 08 '19 at 04:14

3 Answers3

12

In lines 47-51 of the virtualenvwrapper.sh script, it first checks to see if the environment variable VIRTUALENVWRAPPER_PYTHON is set, and if not, it sets it in line 50:

VIRTUALENVWRAPPER_PYTHON="$(command \which python)"

The problem is that newer versions of Ubuntu (18.04+) no longer come with the binary python installed, only python3. Change python to python3 in line 50 of the script and you're all set ;)

Otherwise, in .bashrc, you need to first set VIRTUALENVWRAPPER_PYTHON and then source the script:

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
mladmon
  • 121
  • 1
  • 4
2

In short, virtualenvwrapper.sh is part of a Python package.

I ran into this on a new Ubuntu 18.04 installation. I checked my logs on an older machine and found the following:

sudo -H pip3 install virtualenvwrapper
sudo -H pip  install virtualenvwrapper

When I ran them on the new machine, the error message went away.

0

I ended up solving this by rearranging the exports to this:

export WORKON_HOME=~/Env
source /usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
W. Reyna
  • 171
  • 1
  • 4