我几乎不喜欢夹层。
之前,我试图使用此代码创建Datebase。
$ python manage.py createdb
然后,发生了一个错误。
这里是每个版本和环境。
环境
pc:mac os 10.13.1
版本
蟒蛇:3.6.2
夹层:4.3.1
django:1.11.16
mysqlclient:1.3.13
而且,这是错误。
Traceback (most recent call last):
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 26, in <module>
import MySQLdb as Database
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/MySQLdb/__init__.py", line 18, in <module>
import _mysql
ImportError: dlopen(/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
Referenced from: /Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/models/base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
Referenced from: /Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found.
Did you install mysqlclient or MySQL-python?
(anaconda3-5.0.0) ➜ liongarden git:(2_making_sample_page) ✗ pip freeze | grep mysql
mysqlclient==1.3.13
(anaconda3-5.0.0) ➜ liongarden git:(2_making_sample_page) ✗ python manage.py createdb
Traceback (most recent call last):
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 26, in <module>
import MySQLdb as Database
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/MySQLdb/__init__.py", line 18, in <module>
import _mysql
ImportError: dlopen(/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
Referenced from: /Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/models/base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
Referenced from: /Users/{ThisIsMyName}/.pyenv/versions/anaconda3-5.0.0/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
Reason: image not found.
Did you install mysqlclient or MySQL-python?
如Did you install mysqlclient or MySQL-python
所述,我已经确认了mysqlclient版本。而且,在我的电脑中。
所以我不明白错误要我做什么。