对于OSX 10.6用户来说,这是一个经常讨论的问题,但我还没有找到一个有效的解决方案.以下是我的设置:

Python 2.6.1 64位

我创建了一个虚拟说唱歌手,没有网站包,然后安装了Django.当我激活virtualenv并运行python manage时.py syncdb,我得到这个错误:

Traceback (most recent call last):
File "manage.py", line 11, in <module>
  execute_manager(settings)
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
  utility.execute()
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/core/management/__init__.py", line 257, in fetch_command
  klass = load_command_class(app_name, subcommand)
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class
  module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
  __import__(name)
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 7, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/core/management/sql.py", line 5, in <module>
from django.contrib.contenttypes import generic
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/contrib/contenttypes/generic.py", line 6, in <module>
  from django.db import connection
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/db/__init__.py", line 75, in <module>
  connection = connections[DEFAULT_DB_ALIAS]
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/db/utils.py", line 91, in __getitem__
  backend = load_backend(db['ENGINE'])
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/db/utils.py", line 32, in load_backend
  return import_module('.base', backend_name)
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
  __import__(name)
File "/Users/joerobinson/.virtualenvs/dj_tut/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
  raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

我也安装了MySQL for Python适配器,但没有用(可能是安装不当?).

以前有人处理过吗?

推荐答案

此问题是由于MySQL for Python适配器安装不完整/不正确造成的.具体地说,我必须编辑mysql_config文件的路径,使其指向/usr/local/mysql/bin/mysql_config-本文更详细地讨论了/usr/local/mysql/bin/mysql_config:http://dakrauth.com/blog/entry/python-and-django-setup-mac-os-x-leopard/

Python相关问答推荐

取相框中一列的第二位数字

我可以使用极点优化这个面向cpu的pandas代码吗?

Python中使用Delivercio进行多个请求

Python中的Pool.starmap异常处理

GEKKO:已知延迟的延迟系统的参数估计

在Transformer中使用LabelEncoding的ML模型管道

Tkinter滑动条标签.我不确定如何删除滑动块标签或更改其文本

无法使用python.h文件; Python嵌入错误

Python会扔掉未使用的表情吗?

如何比较numPy数组中的两个图像以获取它们不同的像素

通过Selenium从页面获取所有H2元素

使用groupby Pandas的一些操作

Python中绕y轴曲线的旋转

如何使用scipy的curve_fit与约束,其中拟合的曲线总是在观测值之下?

如何启动下载并在不击中磁盘的情况下呈现响应?

如何禁用FastAPI应用程序的Swagger UI autodoc中的application/json?

基于行条件计算(pandas)

如何杀死一个进程,我的Python可执行文件以sudo启动?

基于另一列的GROUP-BY聚合将列添加到Polars LazyFrame

从一个df列提取单词,分配给另一个列