When running a Python CGI script on Apache2, the server is unable to import certain python modules. For example, Pandas is installed locally:
And this is the script I want to run from the /var/www/html directory:
But the python script keeps giving an import error for pandas when running from the web. I have changed the shebang line a few times thinking that it could be an issue. I've tried /usr/bin/python3, /usr/bin/env python3, /usr/bin/python3.5 and /usr/bin/env python3.5 but it doesn't seem to make a difference.
I'm wondering if it's to do with permissions for the site-packages directory seeing as it's outside the web directory. Or if a completely different python environment is used when the CGI script is executed from the web. This is the site configuration:
Are there any additional authorizations that would allow for local modules to be called or is there another solution for this?