2017-02-14 80 views
1

环境: visualvenv python3.6导入错误:没有模块名为 'ConfigParser'

开始Django的在VENV, mysqlRemind没有联系

开始Django的在VENV, mysqlRemind没有联系 开始Django in venv, mysqlremind no linkStart Django in venv, mysqlRemind no linkStart Django in venv, mysqlRemind no linkStart Django in venv, mysqlremind no linkStart Django in venv , 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/ 
+0

[Python 3 ImportError:No module named'ConfigParser'](http://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser) – Bugs

回答

3

这个问题是在GitHub上的官方回购here上市:

This change should do it. There were some minor incompatibilities with python 3 within django-mysqlndb-backend itself, but also the MySQL-python dependency is not python 3 compatible (which is where your ConfigParser error was coming from), whereas mysqlclient is. You may need to uninstall MySQL-python before reinstalling django-mysqlndb-backend in order for it to pull in the correct package.

Unfortunately someone created a PyPI package for this library on our behalf (it appears that it might be @enriqueaf ?) So unless they give the PyPi user "theatlantic" write access to that package you will just have to pip install from source. I recommend pinning it to a tag, e.g.:

pip install -e git+git://github.com/theatlantic/[email protected]#egg=django-mysqlndb-backend 

的问题也被问过SO

+0

编辑。 谢谢你@Bugs – Geoffroy

+1

对不起,是一个球破坏者。我知道你是新人,所以不要以为我一直在走。只是想帮助。有了链接,你应该在你的回答中提供环境链接,以防链接死亡。看看[如何撰写出色的答案](http://stackoverflow.com/help/how-to-answer)。具体而言,我们鼓励与外部资源的链接,但请在链接中添加上下文,以便您的同行用户可以了解它是什么以及它为什么在那里。如果目标网站无法访问或永久离线,请务必引用重要链接中最相关的部分._ – Bugs

+0

不用担心,再次感谢! @Bugs – Geoffroy

相关问题