garnerbo
By:
garnerbo

Problem installing python modules

April 29, 2016 1k views
Python MySQL

I am runnung an ubuntu server. I installed pymysql with pip. I also ran the python console and did an import command "import pymysql" with no error. However, when I run my program the server gives me an error: "ImportError: No module named pymysql". I had the same error with the flask module but solved this my installing python-flask through apt. I did install python-mysqldb through apt but this did not solve the problem.

Here is the complete error log.

[Fri Apr 29 13:43:17.323554 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833] mod_wsgi (pid=17823): Target WSGI script '/var/www/crimemap/crimemap.wsgi' cannot be loaded as Python module.
[Fri Apr 29 13:43:17.323620 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833] mod_wsgi (pid=17823): Exception occurred processing WSGI script '/var/www/crimemap/crimemap.wsgi'.
[Fri Apr 29 13:43:17.323664 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833] Traceback (most recent call last):
[Fri Apr 29 13:43:17.323711 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833]   File "/var/www/crimemap/crimemap.wsgi", line 3, in <module>
[Fri Apr 29 13:43:17.323821 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833]     from crimemap import app as application
[Fri Apr 29 13:43:17.323840 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833]   File "/var/www/crimemap/crimemap.py", line 1, in <module>
[Fri Apr 29 13:43:17.323931 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833]     from dbhelper import DBHelper
[Fri Apr 29 13:43:17.323959 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833]   File "/var/www/crimemap/dbhelper.py", line 1, in <module>
[Fri Apr 29 13:43:17.324033 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833]     import pymysql
[Fri Apr 29 13:43:17.324069 2016] [:error] [pid 17823:tid 139734320318208] [remote 174.101.129.150:51833] ImportError: No module named pymysql

code
1 comment
  • Hi! Please post the output that you get when you run:

    import sys
    print sys.path
    

    That should output the list of directories that python looks in when it tries to import a module.

Be the first one to answer this question.