Skip to content

aml base image can't load python 3 after setting up a release

I tried to do the following

docker run -it --rm atlasml/atlasml-base bash
. release_setup.sh
python3

Expected result

python3 command prompt opens

Actual result

Fatal Python error: Py_Initialize: Unable to get the locale encoding

Workaround

Setting up the release seems to set a few variable that mess with every python installation. By resetting PATH to only include

/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin

and unsetting the PYTHONPATH variable, I was able to revive python 3. I'm not completely sure the PATH reset is required, but the PYTHONPATH reset definitely is. Unfortunately this defeats the purpose of having both these things in one image.

Possible Fix

Python supports a number of other ways of adding things to the path. In particular, we could simply write a analysisbase.pth file and put it somewhere in the default python 2 path.

Edited by Matthew Feickert