Score:3

Python error in terminal

in flag

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
cjs avatar
ae flag
cjs
The stand-alone dot is the [`source` command](https://www.gnu.org/software/bash/manual/bash.html#index-_002e); it's exactly the same as if it were `source /usr/local/bin/virtualenvwrapper.sh`.
Score:7
jp flag

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.

Gi Na avatar
me flag
How can I test which programs should be upgraded? Should I upgrade by default? Is there a standard procedure?
Raffa avatar
jp flag
@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.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.