# py-MySQLdb installed but getting ImportError: No module named MySQLdb



## freebsdinator (Apr 19, 2018)

I'm attempting to install all of my python dependencies through ports, but I'm getting:

ImportError: No module named MySQLdb

Even after installing the port py-MySQLdb.

The import line is:
import MySQLdb as mysql

Is there an issue with my import line? Is there some method that I need to reference the installed port in the virtual python environment? If there's a document, please let me know. The closest I could find was a post on SO which discussed what to install for FreeBSD, but no further context. https://stackoverflow.com/questions/454854/no-module-named-mysqldb

edit:
I have the same issue for numpy, despite also having installed audio/py-SoundFile. I feel like it's something trivial, but I can't find the answer.

edit2:
I attempted to install numpy with the p27 flavor by:
make -C /usr/ports/math/py-numpy FLAVOR=py27 install

But my virtual environment still produces the same error. Is there an extra step to have this translate to the virtual environment?


----------



## freebsdinator (Apr 19, 2018)

The make command above seems to work as I slowly compile the necessary packages from ports. Could someone point me to a quick way to 'refresh' the virtual environment? I'm having to recreate it (and check a box saying use packages from main environment) after I install from ports, but it's from a GUI.


----------

