Fixing your python environment#
Sure, python / anaconda environments are a nice thing. However, sometimes they do break. Sometimes it is hard to figure out, why.
This tutorial assumes that you have installed anaconda/miniconda according to
the tutorial
and you have also created the environment in the .venv
folder using an environment.yml
file as described here.
Do this first#
The first thing you can always try is to delete and regenerate your environment.
conda deactivate
rm -r .venv
mamba env create -p ./.venv
conda activate ./.venv
I get a strange error involving GLIBC
#
This normally looks like this:
ImportError: /mnt/obob/staff/jdoe/temp/test_for_tutorial/.venv/lib/python3.10/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /mnt/obob/staff/jdoe/temp/test_for_tutorial/.venv/lib/python3.10/site-packages/scipy/fft/_pocketfft/pypocketfft.cpython-310-x86_64-linux-gnu.so)
It basically means that some package that gets imported needs some library and does not find the correct version of it.
You can try the following things:
Recreate your environment
Add
libgcc-ng
andlibstdcxx-ng
as dependencies to yourenvironment.yml
.Reinstall miniconda:
Deactivate your environment.
Find out, where miniconda was installed:
which conda
should give you the path.Let’s say, it is:
/mnt/obob/staff/jdoe/bin/miniconda
, typerm -r /mnt/obob/staff/jdoe/bin/miniconda
Delete and recreate your environment.
Find out which package causes the error and downgrade it by one version.
Look at the error message and search for the part that starts with
(required by...)
.Look for what is written after
site-packages
. This is the package causing trouble.In our case, that is
scipy
.Type
conda list
to get a list of all installed packages.Look for the offending package in the list and note the version number right next to it.
Go to the
environment.yml
file and see whether the package is already required there.If yes, go to that line and exclude this version. In our case it would look like:
- scipy!=1.8.1
If no, add a line explicitly requiring that the package does not install at the offending version.
Type:
mamba env update -p ./.venv