I am trying to set up MySQL, and can't seem to be able to enter the Django manage.py shell interpreter. I did install MySQL-python but that did not solve the issue.
我正在尝试设置MySQL,而且似乎无法进入Django管理。py壳翻译。我确实安装了sql - myl -python,但这并没有解决问题。
Getting the output below:
下面的输出:
rrdhcp-10-32-44-126:django pavelfage$ python manage.py shell
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/shell.py", line 45, in handle_noargs
from django.db.models.loading import get_models
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 24, in load_backend
return import_module('.base', backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named _mysql
Any suggestions really appreciated.
任何建议非常感激。
2 个解决方案
#1
1
You are probably missing the MySQLdb
module. You basically just have to install it.
您可能会丢失MySQLdb模块。你只需要安装它。
By the looks of it, you are using a Mac, so you might want to check out this answer for detailed installation instructions: How to install MySQLdb (Python data access library to MySQL) on Mac OS X?
从它的外观来看,您正在使用Mac,因此您可能想要查看这个答案以获得详细的安装说明:如何在Mac OS X上安装MySQLdb(将Python数据访问库安装到MySQL) ?
On a totally alternate solution, as you mentionned Django development you might want to use sqlite3
instead of MySQL
, which could be simpler to install.
在另一种完全不同的解决方案中,当您提到Django开发时,您可能希望使用sqlite3而不是MySQL,这可能更容易安装。
#2
0
You should be able to import MySQLdb from python shell. Try importing MySQLdb from python shell not django
您应该能够从python shell中导入MySQLdb。尝试从python shell中导入MySQLdb而不是django
If you can not import MySQLdb from python shell; It may caused because of 32-64 bit mismatch,
如果不能从python shell中导入MySQLdb;可能是由于32-64位不匹配造成的,
Try this link
试试这个链接
#1
1
You are probably missing the MySQLdb
module. You basically just have to install it.
您可能会丢失MySQLdb模块。你只需要安装它。
By the looks of it, you are using a Mac, so you might want to check out this answer for detailed installation instructions: How to install MySQLdb (Python data access library to MySQL) on Mac OS X?
从它的外观来看,您正在使用Mac,因此您可能想要查看这个答案以获得详细的安装说明:如何在Mac OS X上安装MySQLdb(将Python数据访问库安装到MySQL) ?
On a totally alternate solution, as you mentionned Django development you might want to use sqlite3
instead of MySQL
, which could be simpler to install.
在另一种完全不同的解决方案中,当您提到Django开发时,您可能希望使用sqlite3而不是MySQL,这可能更容易安装。
#2
0
You should be able to import MySQLdb from python shell. Try importing MySQLdb from python shell not django
您应该能够从python shell中导入MySQLdb。尝试从python shell中导入MySQLdb而不是django
If you can not import MySQLdb from python shell; It may caused because of 32-64 bit mismatch,
如果不能从python shell中导入MySQLdb;可能是由于32-64位不匹配造成的,
Try this link
试试这个链接