4

After upgrading from Ubuntu 20.04 to 22.04 I get this error whenever I open a terminal:

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

This is what is in my ~/.bashrc file:

#Virtualenvwrapper settings:
export WORKON_HOME=$HOME/.virtualenvs
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
. /usr/local/bin/virtualenvwrapper.sh

I note there is a space after the dot on the last line. Should that be there?

mike@orac:/usr/bin$ ls -la /usr/bin/python3
lrwxrwxrwx 1 root root 10 Aug 18 22:39 /usr/bin/python3 -> python3.10
Jedi
  • 491

1 Answers1

7

The space after the dot . in:

. /usr/local/bin/virtualenvwrapper.sh

should be there ... That is a way of how a file is sourced ... But, the error:

(ModuleNotFoundError: No module named 'virtualenvwrapper')

Indicates that the module virtualenvwrapper is either not installed or outdated ... You can fix both with:

pip3 install -U virtualenvwrapper

If pip3 isn't installed, install it first with:

sudo apt install python3-pip

Why after the upgrade?

/usr/bin/python3

will always be a symbolic link to the current system python version ... i.e. it will point to the newly upgraded Ubuntu 22.04 python3.10 like so:

ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 10 Aug 18 13:39 /usr/bin/python3 -> python3.10

While it previously pointed to the previous Ubuntu 20.04 python3.8 like so:

ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 10 Aug 18 13:39 /usr/bin/python3 -> python3.8

This change might require reinstalling or upgrading previously installed modules to work correctly with the new system python.

Raffa
  • 32,237
  • How can I test which programs should be upgraded? Should I upgrade by default? Is there a standard procedure? – giammi56 Feb 28 '23 at 07:45
  • 1
    @giammi56 Please see https://askubuntu.com/a/1456676/968501 ... Some modules are not automatically ported to new versions by default ... You can follow the notice part in the linked answer to list and test run modules by version and update/install accordingly. – Raffa Feb 28 '23 at 09:27