Forums

Cannot Import Pymysql

I have already made my web app offline, but would like to get it running here. I've set up my database on a mysql console, and I installed pymysql on another virtualenv console, receiving this response in my virtualenv:

Installing collected packages: pymysql
Successfully installed pymysql-0.7.6

Yet when I run the following code in my flask_app.py file:

import pymysql

I receive the error:

File "/home/ryanpe05/mysite/flask_app.py", line 3, in <module>
import pymysql
ImportError: No module named 'pymysql'

Any ideas as to what is causing the issue? I don't see a lot of other posts talking about pymysql.

Make sure that your webapp virtualenv settings are correct.

Hi Conrad, thanks for the help. I figured that might have been the problem, so I added myvirtualenv to the Virtualenv path on my home page, but it keeps telling me that the virtualenv is using python 2.7 instead of 3.5. Yet when I open a console in the virtualenv, I see this:

(myvirtualenv) 08:57 ~ $ python
Python 3.5.1 (default, Dec 18 2015, 00:00:00)

I've tried refreshing the home page, but that doesn't seem to work either. Any tips?

try deleting the virtualenv and recreating it? that sounds like you tried to install over the old virtualenv and there is both python2.7 and 3.5 in it.

can run pymysql on my app

Yes, you can use it -- see this help page for information on installing Python modules for your account.