I am running a python script on a local server (my OS is Ubuntu 20.04). The script is located here:
/var/www/html/myfoo.py
I need to use numpy module. The module is located here:
/home/namae/.local/lib/python3.8/site-packages
I am appending the module:
try:
import sys
sys.path.append('/home/namae/.local/lib/python3.8/site-packages')
import numpy
except Exception as e:
print(e)
I am getting an error: No module named 'numpy'
I don't understand what I'm doing wrong
Update:
- Unfortunately, I ran into difficulties at the stage of installing conda and following the suggested solution.
sys.executableis/usr/bin/python3ls -lsa $(which python)gives me in the working dir:
4 -rw-r--r-- 1 root root 123 Apr 26 00:53 myfoo.py
- The following helped me:
sudo cp /home/namae/.local/lib/python3.8/site-packages/numpy* /var/www/html/
Use conda.
Create an
environment.yml:Activate the environment. Observe that
silently succeeds.