Ubuntu : Python3.8 - Apache2 - WSGI - Numpy Module not found error

Viewed 465

I looked up at many threads describing this issue but I can not find the issue / solution to my problem. I have installed apache2/wsgi roughly following Tutorial by adjusting for python3.8. The hello world page works fine. Now when I point it to my dash application I am getting error ( in the app-error file) which says it can not find numpy module. The module is installed as I can execute the application.py file and the local version of app works just fine. Here are the basic set up / checks I did:

  1. Ran LDD on the .so file per output of od_wsgi-express module-config and verified it points to python38 folder .

  2. my wsgi file points to python3.8 using

    #!/usr/bin/python3.8

  3. One thing I noticed is that when I run python command it points to python2.7 and numpy indeed is not installed on it. I think that's the issue but I am not sure why wsgi is not using python3.8.

  4. On the same notes I put the sys.path as output in a test.py file and used that as output and it indeed points to 3.8 folders so not sure how numpy can be missing. Can this be an folder permission issue?

  5. I tried to do virtualenv too but keep running into error related to setuptools / linux distribution.

EDIT: Does it matter if my python code is not in /var/www/APP folder? The way its set up is APP.CONF file points to /var/www/app.wsgi file. app.wsgi file is setting path to /usr/myuser/app folder and imports the application from python file there which has the dash app code. since it can find the script I am guessing the path checks out. I did run CHOWN -R for the /usr/myuser/APP folder to give it all permissions.

1 Answers

I had a similar problem but with SciPy. You need to append

WSGIApplicationGroup %{GLOBAL}

to your httpd.conf, which is usually at /etc/httpd/conf/httpd.conf file. The explanation for this is that C extenstions of numpy and scipy run in python's main interpreter, whereas mod_wsgi uses sub-interpreter. Source: https://serverfault.com/a/514251

Related