Approved: Fortect
Sometimes your computer may generate an error indicating an incorrect configuration error when loading the mysqldb django module. This error can have various reasons.
The problem I am facing when trying to connect to a MySQL database. I also specified the parameters of the database being used.
Traceback Last (most calls last): File "Manage.py", 10, line in execute_from_command_line (sys.argv) File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_lineThe utility.execute ()File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages / django / core / management / __ init__.py "connection 392, in progressself.fetch_command (subcommand) .run_from_argv (self.argv)File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, fetch_commandclass as a whole = load_command_class (app_name, subcommand)File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/__init__.py" line seventy-seventh, in load_command_classmodule = import_module ('% s.management.commands.% s'% (app_name, name))File "/home/arundhati/Desktop/test/testprac/local/lib/python2.7/site-packages/django/utils/importlib.Line py", 35, in import_module__import __ (name)File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", 11, line in import custom_sql_for_model, issue_post_sync_signal from django.core.management.sqlFile "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/core/management/sql.Line py", 9, in django.db importance modelsFile "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/__init__.py", line 40, the backend matches load_backend (connection.settings_dict ['ENGINE'])File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__return getattr (connections [DEFAULT_DB_ALIAS], "/ home / ar / Desktop / test / testprac / local / lib / python2 item)File.7 / site-packages / django / db / utils.py ", line 93 means __getitem__backend load_backend (db ['ENGINE'])File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/utils.py", line 27, in import_module('load_backendreturn.base ', backend_name)File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/utils/importlib.Line py", 35, in import_module__import __ (name)File "/home/ar/Desktop/test/testprac/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", order 17, in Raise ImproperlyConfigured ("Error loading MySQLdb module:% s"% e)django.core.Exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named = mysqldb
databases 'Originally': 'ENGINE': 'django.db.backends.mysql', number Add 'postgresql_psycopg2', 'mysql' or 'sqlite3' 'oracle'. 'NAME': 'ar_test_db', # Or path to the main client file if used # The following parameters are not used with sqlite3: 'USER': '', 'PASSWORD': '', 'HOST': '', # Empty for localhost on domain sockets, '127.0.0.1' for localhost on TCP. 'PORT': '', # Defined as an empty string conforming to the standard.
Not The Answer You Are Looking For? Browse Other Questions Tagged Python Mysql Django Phpmyadmin Or Ask Your Own Question.
Approved: Fortect
Fortect is the world's most popular and effective PC repair tool. It is trusted by millions of people to keep their systems running fast, smooth, and error-free. With its simple user interface and powerful scanning engine, Fortect quickly finds and fixes a broad range of Windows problems - from system instability and security issues to memory management and performance bottlenecks.
buy pip pymysql
Then edit the __init__.py file in your product home directory (e.g. settings.py)
import pymysqlpymysql.install_as_MySQLdb ()
satisfied on April 18 at 7:10
2.319
Face the same issue after migrating to Python 3. Obviously MySQL Python is not compatible, as stated in the official Django docs, mysqlclient is installed with pip install mysqlclient
on Mac. Please note that most operating systems have specific issues mentioned in the docs.
Requirements
You may need to set the common Python and MySQL development headers and your local library, so:
Like
sudo apt-get in place python-dev default-libmysqlclient-dev
# Debian / Ubuntu
sudo yum buy python-devel mysql-devel
# Red Hat / CentOS
brew install mysql-connector-c
macOS (Homebrew) number (currently getting an error. See below)
Windows now have binary wheels that can be installed without MySQLConnector / C or MSVC.
Note on Python 3: If you are using Python3, you need to add Python3-dev with the following command:
sudo apt-get install python3-dev
debian / Ubuntu number
sudo yummy install python3-devel
# Red Hat / CentOS
Note on MySQL Connector / C error on macOS
See also: https://bugs.mysql.com/bug.php?id=86971
Versions related to MySQL Connector / C may have incorrect free configuration which causes compilation errors every time mysqlclient-python
is installed. (As of Nov 2017, this applies to homebrews mysql-connector-c
and the official package)
Modifying mysql_config
fixes these tasks as follows.
Edit
# from macOS on line 112 or higher:# Create parameterslibs = "- L $ pkglibdir"libs = "$ libs -l"
in
# Create parameterslibs = "- L $ pkglibdir"libs = "$ libs -lmysqlclient -lssl -lcrypto"
The result of the SSL configuration can also cause problems; see for example beer info for openssl
on macOS.
Installing PyPI
pip install mysqlclient
NOTE. May windows wheels still won’t ship with original package. You will need to commit your version to requirements.txt
to avoid installing the latest source package.
Install from source
- Download the source using
git clone
or Zipfile. - Customization
site.cfg
-
installing python setup.py
satisfied on 30 Jul ’18 at 18:49
5.766 Speed up your computer's performance now with this simple download.