I need to use Numpy on EC2 instance that runs Flask with WSGI-py3, which can be accessed over HTTP.
After setting up everything needed, I can see the page in the browser. However, later I am installing Numpy using pip3 and now the service breaks with the following error in /var/log/apache2/error.log ModuleNotFoundError: No module named 'numpy'
, however I can import numpy in python3 without any problems
What could be done to be able to import numpy in Flask application?
EDIT:
It is confusing.. If I list all Python versions installed, I get:
0 lrwxrwxrwx 1 root root 9 Oct 25 2018 /usr/bin/python3 -> python3.6
0 lrwxrwxrwx 1 root root 16 Oct 25 2018 /usr/bin/python3-config -> python3.6-config
4 -rwxr-xr-x 1 root root 1018 Oct 28 2017 /usr/bin/python3-jsondiff
4 -rwxr-xr-x 1 root root 3661 Oct 28 2017 /usr/bin/python3-jsonpatch
4 -rwxr-xr-x 1 root root 1342 May 1 2016 /usr/bin/python3-jsonpointer
4 -rwxr-xr-x 1 root root 398 Nov 15 2017 /usr/bin/python3-jsonschema
4424 -rwxr-xr-x 2 root root 4526456 Apr 18 01:56 /usr/bin/python3.6
0 lrwxrwxrwx 1 root root 33 Apr 18 01:56 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
4424 -rwxr-xr-x 2 root root 4526456 Apr 18 01:56 /usr/bin/python3.6m
0 lrwxrwxrwx 1 root root 34 Apr 18 01:56 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
0 lrwxrwxrwx 1 root root 10 Oct 25 2018 /usr/bin/python3m -> python3.6m
0 lrwxrwxrwx 1 root root 17 Oct 25 2018 /usr/bin/python3m-config -> python3.6m-config
-
pip3
seems to be connected topython3.6
-
/usr/local/bin/flask
uses#!/usr/bin/python3
-
If I install numpy using
/usr/bin/python3 -m pip install numpy
I still have the same problem
2
Answers
Using virtual environment in EC2 has helped:
This probably means, the Python interpreter which runs Flask is a different than the Python interpreter which you have installed
numpy
into.Unfortunately, I have no experience with AWS.
Basically, you have to figure out how to find the Python interpreter you installed Flask with.