加载MySQLdb模块时出错:没有名为MySQLdb的模块AFTER virutalenv

时间:2017-05-18 17:38:47

标签: python mysql django virtualenv mysql-python

好的,我一直在倾倒这个网站和谷歌但无法找到正确的答案。我应该首先提到我对这些东西不熟悉。

我完成了50%的django项目。我正在使用virtualenv在Linux中构建它。出于某种原因,当我在项目目录中时,我决定输入'virualenv'。不知道这是做什么的,假设它覆盖了我当前的设置,但现在一切都坏了。我正在努力解决这一切。我正在使用python 2.7,但我得到以下回溯:

    enter code here  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
    class AbstractBaseUser(models.Model):
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/db/models/base.py", line 124, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/db/models/base.py", line 330, in add_to_class
    value.contribute_to_class(cls, name)
  File "/root/IPNV/django-test/local/lib/python2.7/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 "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/db/__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/db/utils.py", line 211, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/root/IPNV/django-test/local/lib/python2.7/site-packages/django/db/utils.py", line 115, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/root/IPNV/django-test/local/lib/python2.7/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: No module named MySQLdb.

我尽我所能地解决了这个问题。我用mysqldb-python试过apt-get pip,连接一切。我错过了什么?????

0 个答案:

没有答案