1

I created a virtual environment with python 3.5 then used pip to install mysqlclient. When I activate the venv and go into the python shell I can type import MySQLdb and then proceed to query my db without any trouble. However, in django 1.10.5 when I use this virtual environment I get ImportError: No module named 'MySQLdb' as soon as I start the local/dev server. For what it's worth, I also tried this process outside of a virtual environment but no success.

I'm on windows and Pycharm and created the venv in CMD with administrator privileges. I know there are similar questions on SO but nothing is on point here. Thanks for whatever help you can give!

My settings are:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'my_db_name',
        'USER': 'my_user_name',
        'PASSWORD': 'my_password',
        'HOST': '127.0.0.1',
        'PORT': '3306'
    }
}
r_zelazny
  • 517
  • 3
  • 19

1 Answers1

0

It looks like you are missing a MySQL module for Python.

Run this:

pip install mysql-python

Make sure you install this under your virtualenv.

Sazzy
  • 1,924
  • 3
  • 19
  • 27
  • Perhaps not surprisingly I get an error when I try to install this with pip...looking past that for a moment, do I need this module and mysqlclient? Thanks for the help... – r_zelazny Feb 09 '18 at 19:57
  • Generally, you need either `PyMySQL` or `mysql-python` modules. These should include all you will need to connect to MySQL database using Django. – Sazzy Feb 09 '18 at 20:00