无法为django/python3安装msqlclient [OSX 10.12.4] [英] Can't install msqlclient for django/python3 [OSX 10.12.4]

查看:116
本文介绍了无法为django/python3安装msqlclient [OSX 10.12.4]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行python3 manage.py runserver时,我收到以下消息:

when I'm running python3 manage.py runserver I get this message:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. 
Did you install mysqlclient or MySQL-python?

并且因为我在python上使用mysql数据库,所以尝试使用pip3安装mysqlclient时出现另一个错误:

and because I'm using mysql database on python, I tried to install mysqlclient with pip3 I get another error:

Collecting mysqlclient
  Using cached mysqlclient-1.3.10.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup_posix.py", line 54, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/setup_posix.py", line 12, in dequote
        if s[0] in "\"'" and s[0] == s[-1]:
    IndexError: string index out of range  

       ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-wt6g2_0e/mysqlclient/

我还在线阅读了python3不支持mysqlclient的信息,但在尝试安装MySQL-python时却遇到了类似的错误:

Also i read online that mysqlclient is not supported by python3 but i get a similar error when trying to instal 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/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-jp09s51k/MySQL-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-jp09s51k/MySQL-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'

     ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/dd/vlr9cjt17_j4ccyzz89mld1w0000gn/T/pip-build-jp09s51k/MySQL-python/

如何解决此问题并为python安装mysql客户端,或者还有其他方法可以在python中使用MySQL数据库?

How can I fix this and install mysql client for python or is there other method so I could use MySQL db in python?

python3确实支持mysqlclient,但不支持MySQL-python.

python3 does support mysqlclient but not MySQL-python.

推荐答案

我不确定我做了什么,但是我认为我的问题是我的$PATH不好.我尝试执行在Google上找到的步骤之一,并重置bash_profile并再次设置Python路径后,它已为我修复.

I'm not sure what I did, but I think the problem for me was that I had a bad $PATH. I was trying to do one of the steps I found on Google and after resetting the bash_profile and setting the Python path again, it was fixed for me.

这篇关于无法为django/python3安装msqlclient [OSX 10.12.4]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆