首页 文章

找不到Pycharm Django Syncdb MySQLdb

提问于
浏览
1

我已经开始使用Pycharms进行我的django开发并且遇到了这个错误 . 我知道我的MySQLdb正在工作,因为我可以在进入python shell时导入它,并且我可以在命令行上运行syncdb命令 . 我的问题是我需要添加到Pycharms中才能识别MySQLdb . 我正在使用Mac OS X,如果这有任何区别 . 我是否需要在manage.py中添加内容或者是否需要将其添加到Pycharms首选项中?或者它是一起不同的东西 . 谢谢你的帮助 .

这是我得到的错误:

回溯(最近一次调用最后一次):文件"/Applications/PyCharm.app/helpers/pycharm/django_manage.py",第21行,在run_module中(manage_file,无,' main ',True)文件"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py",第176行,在run_module中为fname,loader,pkg_name)文件"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py",第82行,在_run_module_code mod_name中,mod_fname,mod_loader,pkg_name)文件"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py",第72行,在run_globals中的_run_code exec代码文件"/Users/Brandon/PycharmProjects/Database_assignment/manage.py",第10行,在execute_from_command_line(sys.argv)文件“/Library/Python/2.7/site-packages/django/core/management / init .py ", line 443, in execute_from_command_line utility.execute() File " /Library/Python/2.7/site-packages/django/core/management/ init .py ", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File " /Library/Python/2.7/site-packages/django/core/management/ init .py ", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File " / Library / Python / 2.7 / site-packages / django / core / management / init .py ", line 69, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File " /Library/Python/2.7/site-packages/django/utils/importlib.py“,第35行,在import_module import (名称)文件"/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py",第8行,从django.core.management.sql导入custom_sql_for_model,emit_post_sync_signal文件"/Library/Python/2.7/site-packages/django/core/management/sql.py",第6行,来自django.db导入模型Fil e“/Library/Python/2.7/site-packages/django/db/ init .py ", line 40, in backend = load_backend(connection.settings_dict['ENGINE']) File " /Library/Python/2.7/site-packages/django/db/ init .py”,第34行,在 getattr 中返回getattr(连接[DEFAULT_DB_ALIAS],item)文件"/Library/Python/2.7/site-packages/django/db/utils.py",第92行,在 getitem 后端= load_backend(db ['ENGINE'])文件"/Library/Python/2.7/site-packages/django/db/utils.py",第24行,在load_backend中返回import_module('.base',backend_name)文件"/Library/Python/2.7/site-packages/django/utils/importlib.py",第35行,在import_module import (名称)文件"/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py",第16行,in raise ImproperlyConfigured("Error loading MySQLdb module: %s"%e)django.core.exceptions.ImproperlyConfigured:加载MySQLdb模块时出错:没有名为MySQLdb的模块

进程以退出代码1结束

3 回答

  • 0

    尝试

    pip install mysql-python

    我想在Pycharm中你可以通过GUI安装软件包 . 但实质上你需要安装mysql-python

    如果你收到“Permission denied messages”,你可能需要做sudo pip install mysql-python

  • 0

    PyCharm定义了用于每个项目的解释器,因此您需要仔细检查项目是否设置为使用:

    • 你设置的virtualenv

    • 系统Python,如果你没有使用virtualenv(你应该是) .

  • 0

    如果你使用python 3,mysql-python赢了't install because it doesn' t支持python 3.使用mysqlclient代替 . 更多信息here .

相关问题