Python3.5 + django1.8.5 The solution of the ”;import pymysql pymysql.install_as_MySQLdb()”; installation

Recently in learning Python, intend to first two online tutorial , again in github find several open source project practice , when faced with “ database synchronization in the learning ” is the liberation of the Jiang Ge django cannot perform wrong , records about 。

error phenomenon :

execution python manage.py syncdb , error :Error loading MySQLdb module: No module named ‘MySQLdb’

image

after the Internet search that ,MySQLdb does not support Python3.5, so we will have to find another library instead of 。

Solution :

pymysql replace MySQLdb, because their use exactly the same step , :

1. PIP install pymysql

2. successful execution , open __init__.py, add the following :

import pymysql
pymysql.install_as_MySQLdb()

3. re execution python manage.py syncdb, 。

admin

Leave a Reply