ImportError:没有名为' ConfigParser'

时间:2017-02-14 06:20:37

标签: pip mysql-python

环境: visualvenv python3.6

在venv中启动Django, mysqlRemind没有链接

在venv中启动Django, mysqlRemind没有链接 在venv中启动Django, mysqlRemind没有link在Venv中启动Django, mysqlRemind没有link在Venv中启动Django, mysqlRemind没有link在Venv中启动Django, mysqlRemind没有link在Venv中启动Django, mysqlRemind没有链接

python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x103a88048>
Traceback (most recent call last):
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 24, in <module>
    import MySQLdb as Database
ImportError: No module named 'MySQLdb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
    autoreload.raise_last_exception()
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
    six.reraise(*_exception)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/contrib/auth/models.py", line 41, in <module>
    class Permission(models.Model):
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/models/base.py", line 139, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/models/base.py", line 324, in add_to_class
    value.contribute_to_class(cls, name)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/models/options.py", line 250, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/__init__.py", line 36, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/utils.py", line 241, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/utils.py", line 112, in load_backend
    return import_module('%s.base' % backend_name)
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/VANXV/python/venvdjango186/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 27, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
 pip install MySQL-python
    Collecting MySQL-python
      Using cached MySQL-python-1.2.5.zip
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/b2/3clz71qj661cjh_b3wg2jqcm0000gn/T/pip-build-zqh44_1k/MySQL-python/setup.py", line 13, in <module>
            from setup_posix import get_config
          File "/private/var/folders/b2/3clz71qj661cjh_b3wg2jqcm0000gn/T/pip-build-zqh44_1k/MySQL-python/setup_posix.py", line 2, in <module>
            from ConfigParser import SafeConfigParser
        ImportError: No module named 'ConfigParser'

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/b2/3clz71qj661cjh_b3wg2jqcm0000gn/T/pip-build-zqh44_1k/MySQL-python/

1 个答案:

答案 0 :(得分:3)

此问题列在github官方回购here上:

  

这种改变应该这样做。在django-mysqlndb-backend本身内部与python 3存在一些轻微的不兼容性,但是MySQL-python依赖性也不是python 3兼容的(这是你的ConfigParser错误来自的地方),而mysqlclient是。您可能需要在重新安装django-mysqlndb-backend之前卸载MySQL-python,以便它能够提供正确的包。

     

不幸的是有人代表我们为这个库创建了一个PyPI包(似乎它可能是@enriqueaf?)所以除非他们给PyPi用户&#34; theatlantic&#34;写入对该包的访问权限,您只需从源代码中进行pip安装即可。我建议将其固定到标签上,例如:

pip install -e git+git://github.com/theatlantic/django-mysqlndb-backend.git@v1.1.0#egg=django-mysqlndb-backend

SO也提出了这个问题。