You can't import modules from your ppa python because the environmental variables are still pointing to the system version.
Don't install python or python modules (like numpy) from ppa. It makes your file system very confusing and installing python modules like numpy with sudo apt install python3-numpy is bad idea anyway. I never install python modules from repo,-- except as dependencies for other things installed with apt. There is no need to install them system wide and you get stuck with old versions, and you can't have multiple versions like you have observed.
My advice: Never use your system python and modules from repository for development. Over time it just becomes very hard to manage.
I have multiple versions of pythons on my 16.04 system. I installed python from source and invoke each with a script like this (for python3.8.2)
Code:
export PREFIX=/home/monkeybrain/opt/python38
export HOME=$PREFIX #for spyder to create separate config instead of using a single config for my user
export PATH=$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export PYTHONUSERBASE=$PREFIX
export PYTHONPATH=$PREFIX/lib/python3.8/site-packages:$PYTHONPATH
I call this python38.conf and place it in /home/monkeybrain/Scripts, so to use python3.8.2 (installed in /home/monkeybrain/opt/python38)
I open the terminal and do
Code:
source ~/Scripts/python38.conf
python
(I made a symlink "ln -s /home/monkeybrain/opt/python38/bin/python3 /home/monkeybrain/opt/python38/bin/python", so I don't have to type python3)
This way each python is separate and self contained and I don't need to install a lot of overheads like conda or use something clumsy like virtualenv (you need one version of python to install other sub-python systems and there are version restrictions)
I install python modules (e.g numpy) for each with pip (or pip3 but I made a symlink so don't need to type "3") It will install the module in the proper places for the version of python in question.
P.S Building python from source is really simple, if you need help I can give you step by step instructions.
Bookmarks