2017-03-20 135 views
0

我剛剛嘗試從我的筆記本電腦(windows 10,pycharm)上檢查一個項目,我正在從github開始工作。我安裝的每一個庫,它需要運行連接器,儘量RUNSERVER並獲得這樣的:Django,mysql;加載MySQLdb模塊時出錯

Unhandled exception in thread started by <function wrapper at 0x046FDEF0> 
Traceback (most recent call last): 
    File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 113, in inner_run 
    autoreload.raise_last_exception() 
    File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception 
    six.reraise(*_exception) 
    File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "C:\Python27\lib\site-packages\django\__init__.py", line 27, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "C:\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate 
    app_config.import_models(all_models) 
    File "C:\Python27\lib\site-packages\django\apps\config.py", line 199, in import_models 
    self.models_module = import_module(models_module_name) 
    File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module 
    __import__(name) 
    File "C:\Python27\lib\site-packages\django\contrib\auth\models.py", line 4, in <module> 
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager 
    File "C:\Python27\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module> 
    class AbstractBaseUser(models.Model): 
    File "C:\Python27\lib\site-packages\django\db\models\base.py", line 119, in __new__ 
    new_class.add_to_class('_meta', Options(meta, app_label)) 
    File "C:\Python27\lib\site-packages\django\db\models\base.py", line 316, in add_to_class 
    value.contribute_to_class(cls, name) 
    File "C:\Python27\lib\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 "C:\Python27\lib\site-packages\django\db\__init__.py", line 33, in __getattr__ 
    return getattr(connections[DEFAULT_DB_ALIAS], item) 
    File "C:\Python27\lib\site-packages\django\db\utils.py", line 211, in __getitem__ 
    backend = load_backend(db['ENGINE']) 
    File "C:\Python27\lib\site-packages\django\db\utils.py", line 115, in load_backend 
    return import_module('%s.base' % backend_name) 
    File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module 
    __import__(name) 
    File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 28, in <module> 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) 
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb 

皮普庫安裝在我的機器上:

pip freeze 
altgraph==0.10.2 
appdirs==1.4.2 
automa==0.1.21 
bdist-mpkg==0.5.0 
click==6.7 
CmdUtils==0.1 
decorator==4.0.11 
Django==1.10.5 
django-bootstrap-themes==3.3.6 
django-bootstrap3==7.1.0 
django-console==0.4.7 
django-mysql==1.1.0 
django-mysql-manager==0.1.4 
django-mysql-pymysql==0.1 
django-registration-redux==1.4 
DjangoMySQLDump==0.1 
future==0.16.0 
HTSQL==2.3.3 
httpsproxy-urllib2==1.0 
humanfriendly==2.4 
Jinja2==2.9.5 
macholib==1.5.1 
MarkupSafe==0.23 
modulegraph==0.10.4 
monotonic==1.2 
mysql==0.0.1 
mysql-autodoc==0.2 
mysql-autoxtrabackup==1.4.5 
mysql-connector==2.1.4 
mysql-connector-python==2.1.5 
mysql-connector-python-rf==2.2.2 
mysql-connector-repackaged==0.3.1 
mysql-corsair==0.0.36 
MySQL-python==1.2.5 
mysql-replay==0.1.24 
mysqlclient==1.3.9 
mysqli==0.5.3 
networkx==1.11 
nltk==3.2.1 
nltk-tgrep==1.0.6 
packaging==16.8 
pid==2.1.1 
py2app==0.7.3 
PyMySQL==0.7.10 
pyparsing==2.1.10 
python-dateutil==1.5 
pytz==2013.7 
PyYAML==3.12 
rake-nltk==1.0.0 
requests==2.11.1 
selenium==3.0.2 
six==1.10.0 
termcolor==1.1.0 
urllib2-file==0.2.1 
urllib2-kerberos==0.1.6 
urllib2-prior-auth==0.2.0 
virtualenv==15.1.0 
zope.interface==4.1.1 

任何想法,我怎麼能解決這個問題?

+0

建立的python-MySQLdb的庫的依賴關係: sudo易於得到建立-DEP中的python-MySQLdb的 安裝Python MySQL的庫: 須藤PIP安裝MySQL-python的 –

+0

@JitendraMeena我更新安裝了庫的問題在我的機器上。 – Amos94

+0

什麼返回pip -V? – simopopov

回答

1

在settings.py中,在import os的下面添加以下內容。

try: 
    import pymysql 
    pymysql.install_as_MySQLdb() 
except: 
    pass 
+0

YES!工作!非常感謝! – Amos94

相關問題