Python modules cannot be found, usually a ImportError no module named X
-
Start python in REPL mode (just type in
python
in the command line to enter python terminal) -
Try importing the module there.
import flask
for example. -
If you get the same
ImportError
the module is not installed, therefore your application cannot use it
- Install the missing modules with sudo and pip.
sudo pip install flask
for example.
-
Go to your project folder. (usually
/var/www/somename/somename
) -
Activate the virtualenv there. (usually
source ./venv/bin/activate
) -
Make sure there is a
(venv)
string at the start of the line
- Install the missing modules with virtualenv activated and pip.
pip install flask
for example.
-
If you are doing the REPL test mentioned above, the package is being importd but the application still cannot read them, so you may need to check permissions
-
Make sure you have that your
.conf
(usually/etc/apache2/sites-available/something.conf
) has theWSGIDaemonProcess
property properly configured and pointing to your virtualenv -
Make sure the virtualenv folder has the correct ownership (
grader:grader
). You can use thechown
command to change this if needed -
Make sure the virtualenv folder has the correct read/write permissions (
drwxr-xr-x
). You can use thechmod
command to change this if needed