I'm getting DLL load failed when I try to run python manage.py runserver. It hapeens when I cd haddygirl and then run the previous command.
C:\Users\Lazxy\haddygirl>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Lazxy\Anaconda3\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Lazxy\Anaconda3\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 54, in
wrapper
fn(*args, **kwargs)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\apps\config.py", line 211, in
import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Lazxy\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\contrib\auth\models.py", line 2, in
<module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\contrib\auth\base_user.py", line 47, in
<module>
class AbstractBaseUser(models.Model):
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\models\base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\models\base.py", line 321, in
add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\models\options.py", line 204, in
contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\Lazxy\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 13,
in <module>
from sqlite3 import dbapi2 as Database
File "C:\Users\Lazxy\Anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\Users\Lazxy\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
The error:
ImportError: DLL load failed: The specified module could not be found.
please help.
Seems that the driver for connect to sqlite are not found by the python installation.
Please share your python version. After Python 2.7.5 sqlite3 is shipped as a builtin dependencies.
Have a try with:
Use the builtin sqlite3
Install for python2
pip install pysqlite
Install for python3
pip install pysqlite3
Related
In my Windows10 ,
I have installed mysqlclient in my venv ( I checked the path venv\Lib\sitepackages found mysqlclient-1.4.6.dist-info\).
however, when I use command to runserver:
>python3 manage.py runserver
get Did you install mysqlclient? error,
details:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\mysql\base.py", line 15, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 109,
in inner_run
autoreload.raise_last_exception()
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_excep
tion
raise _exception[1]
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\options.py", line 204, in contribute_to_
class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\Users\80361576\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\mysql\base.py", line 20, in <module>
) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
environment version:
Windows 10
Python 3.7.8
Django 2.2.12
mysqlclient 1.4.6
I Use Django 3.1.2 with MySQL, and it worked normally with the database.
But affter i've installed Botstrap 4 (pip install bootstrap4) and load it in my Tamplate {% load bootstrap4 %} i get Error:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.0. raised by bootstrap as you can see bellow.
But in my venv i have installed module mysqlclient version 2.0.1 (not 0.10.0). (As PyCharm shows me.)
'pip install mysqlclient' for base python interpreter (in Conda, not in venv) did`t helped.
I don`t understend it.
And how CSS/js library like bootstrap even apply to Database engine?
How to solve it?
"C:\Program Files\JetBrains\PyCharm 2019.3.3\bin\runnerw64.exe" C:\MyProject\venv\Scripts\python.exe C:/MyProgect/MySite/manage.py runserver 8000
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\User\Anaconda3\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\User\Anaconda3\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\User\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\contrib\auth\base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\models\base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\models\base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\models\options.py", line 206, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\utils.py", line 214, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\User\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\User\ITResearch\all_gid_2\venv\lib\site-packages\django\db\backends\mysql\base.py", line 36, in <module>
raise ImproperlyConfigured('mysqlclient 1.4.0 or newer is required; you have %s.' % Database.__version__)
**django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.0.**
Let delete PyMySQL if it installed alongside mysqlclient. Where are conflicts between.
(pip unistall pymysql) if it present in venv.
I want to make a mysql database connection using django, and I have downloaded the mysqlclient packages to do this, but when I use python manage.py makemigrations it throws me the next error:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/models/base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/models/options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
I had alredy install mysql client newer version, if I try to run pip install --upgrade mysqlclient it says:
Requirement already up-to-date: mysqlclient in /Users/paulmirve/anaconda3/envs/myDjangoEnv/lib/python3.7/site-packages (1.4.2.post1)
I'm using a Anaconda virtual enviroment and I have python 3.7.3 installed. Also I'm working on OSX. How can I solve this?
I am getting the following error while executing python3 manage.py dbshell on my mac.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 114, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 315, in add_to_class
value.contribute_to_class(cls, name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/options.py", line 205, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/utils.py", line 202, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 20, in <module>
) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
I have already installed mysqlclient. I have looked at other answers on StackOverflow but none of them seems to work. Please help!
pip3 install mysqlclient
Requirement already satisfied: mysqlclient in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (1.3.12)
Use the below command to solve your issue,
sudo apt-get install libmysqlclient-dev
I was finally able to solve it and hence I am writing a solution of my own question. This should work for anyone using MAC and Python 3.
I did the following:
Step 1: On terminal, I editted the ~/.bash_profile and added the following to the paths:
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH=${PATH}:/usr/local/mysql/bin
alias mysql=/usr/local/mysql/bin/mysql
alias mysql_config=/usr/local/mysql/mysql_config
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
PATH="/usr/local/mysql/bin/:${PATH}"
export PATH
Step 2: Restarted the system. Changes only get affected after a restart.
This worked for me.
I'm new to Django and I am running Django inside a virtualenv on MacOS with python 3.6. The command $python3 manage.py migrate but I keep getting an error asking me to install mysqlclient.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libmysqlclient.20.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 114, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 315, in add_to_class
value.contribute_to_class(cls, name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/options.py", line 205, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/utils.py", line 202, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 20, in <module>
) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
pip3 freeze looks like this:
Django==2.0.1
mysqlclient==1.3.12
pytz==2017.3
Which other driver would I be able to use?
I am running it in the virtual environment that I created. Also pip install MySQL-python doesn't work on my Mac as python 2.7 comes pre-installed and to run Django 2.0, I installed Python 3.6 and for that when I run pip3 install MySQL-python, I get an No Module named 'ConfigParser' error.
Try
pip3 install
Instead of pip install
Since you are using python 3
And check if python3-dev is installed in your system