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
Edit:
After upgrading to 24.04 this solution no longer works:
root@orac:~# pip3 install -U virtualenvwrapper
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
What is the best option? Is virtualenvwrapper a non-Debian-packaged or Debian-packaged application?
Should I do
apt install python3-virtualenvwrapper
or
pipx install virtualenvwrapper
So I went with
sudo apt install virtualenvwrapper
Thank you to itsfoss