question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImproperlyConfigured: MySQL driver not installed!

See original GitHub issue

Hey, guys. I’m trying to connect to my remote MySQL database using Peewee, but I am getting the following error (in a virtual environment):

Traceback (most recent call last):
  File "peewee_test.py", line 2, in <module>
    from student import Student
  File "/Users/Matthew/Desktop/python-mvc/student.py", line 10, in <module>
    db.connect()
  File "/Users/Matthew/Desktop/python-mvc/lib/python3.6/site-packages/peewee.py", line 2467, in connect
    self._state.set_connection(self._connect())
  File "/Users/Matthew/Desktop/python-mvc/lib/python3.6/site-packages/peewee.py", line 3164, in _connect
    raise ImproperlyConfigured('MySQL driver not installed!')
peewee.ImproperlyConfigured: MySQL driver not installed!

student.py

from peewee import *

db = MySQLDatabase(
	host='host_here',
	user='mysql_username_here',
	password='mysql_password_here',
	database='mysql_db_here'
)

db.connect()

class Student(Model):
	firstName = CharField()
	lastName = CharField()

	class Meta:
		database = db

peewee_test.py

from peewee import *
from student import Student

john_doe = Student.create(
	firstName='John', 
	lastName='Doe',
	is_relative=False
)

I installed MySQL via Homebrew. This is the version I have:

mysql  Ver 14.14 Distrib 5.7.12, for osx10.10 (x86_64) using  EditLine wrapper

I also installed PyMySQL as others have suggested here. Others also suggested installing mysql-python, but I get an error when when attempting to install it:

Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/m7/wyjxzv8s5sdbh2jr35tq55y00000gn/T/pip-build-xh7783h6/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/var/folders/m7/wyjxzv8s5sdbh2jr35tq55y00000gn/T/pip-build-xh7783h6/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m7/wyjxzv8s5sdbh2jr35tq55y00000gn/T/pip-build-xh7783h6/mysql-python/

I have two installations of Python on My Mac (running OSX 10.10): Python 2.7 and 3.6. I’m using pip3 to install the above packages.

Thank you for your time!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

20reactions
coleifercommented, Apr 13, 2018

Peewee will work with pymysql or mysql-python. It sounds like you have an issue with your module-import path. This is not an issue with Peewee – I’d suggest trying StackOverflow.

15reactions
coleifercommented, Apr 17, 2019

So for mysql:

  • pymysql is a pure-python mysql client, works with python 2 and 3. Peewee will use attempt to use pymysql first.
  • mysqlclient uses a c extension and supports python 3. It exposes a MySQLdb module. Peewee will attempt to use this module if pymysql is not installed.
  • mysql-python is also called MySQLdb1 and is legacy and should not be used. Since this shares the same module name as mysqlclient, same applies.
  • mysql-connector python pure-python (I think??) supports python 3. To use this driver you can use playhouse.mysql_ext.MySQLConnectorDatabase.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python peewee.ImproperlyConfigured: MySQL driver not ...
I tried to fix this by installing this MySQL Driver. But this changed absolutely nothing. Due to me beeing new to python I...
Read more >
Peewee MySQL problem after upgrade to 19.10 - Ask Ubuntu
Since the 19.10 upgrade Python peewee can't talk to MySQL anymore: raise ImproperlyConfigured('MySQL driver not installed!') peewee.
Read more >
peewee 出现MySQL driver not installed!_见见大魔王的博客
ImproperlyConfigured : MySQL driver not installed!原因分析:peewee不会自己安装驱动,需要手动安装解决方案:pip install pymysql.
Read more >
peewee.ImproperlyConfigured: MySQL driver not installed!
ImproperlyConfigured : MySQL driver not installed! peewee自己竟然不去安装驱动,那就自己安装. 解决. pip install pymysql.
Read more >
peewee.ImproperlyConfigured: MySQL driver not installed!
【摘要】 在新的环境做部署的项目中使用了peewee,运行后报错peewee.ImproperlyConfigured: MySQL driver not installed! 1 peewee自己竟然不去安装 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found