2017-10-08 4 views
0

J'utilise python 2.7 sur Mac 10.13 J'ai déjà MySQL sur mon Mac, mais quand je veux installer MySQL-python, continue d'avoir des erreurs.essayer d'installer MySQL-python sur Mac mais en gardant des erreurs

J'ai essayé pip:

sudo pip installer mysql-python

mais a obtenu:

Collecting mysql-python 
    Downloading MySQL-python-1.2.5.zip (108kB) 
    100% |████████████████████████████████| 112kB 1.9MB/s 
    Complete output from command python setup.py egg_info: 
    Traceback (most recent call last): 
     File "<string>", line 1, in <module> 
     File "/private/tmp/pip-build-AhyoBa/mysql-python/setup.py", line 17, in <module> 
     metadata, options = get_config() 
     File "setup_posix.py", line 53, in get_config 
     libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ] 
     File "setup_posix.py", line 8, 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/tmp/pip-build-AhyoBa/mysql-python/ 

Alors j'ai essayé de déplacer le fichier directement sur '-package du site' et a fonctionné:

python /Users/dandizhao/Downloads/MySQL-python-1.2.5/setup.py install 

mais toujours obtenu:

Traceback (most recent call last): 
    File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup.py", line 17, in <module> 
    metadata, options = get_config() 
    File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup_posix.py", line 32, in get_config 
    metadata, options = get_metadata_and_options() 
    File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup_common.py", line 12, in get_metadata_and_options 
    metadata = dict(config.items('metadata')) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 642, in items 
    raise NoSectionError(section) 
ConfigParser.NoSectionError: No section: 'metadata' 

vraiment épuisé ... J'ai essayé de nombreuses méthodes que je peux trouver, mais aucun d'entre eux fonctionne ...

Répondre

2

Je suis allé sur this link here et il semble que cela est très commun problème avec MySQL et MacOS.

Donnez ces commandes essayer dans votre terminal

$ brew uninstall mysql 
$ brew install mysql-connector-c 
$ brew unlink mysql-connector-c 
$ brew install mysql 
$ pip install mysql-python 
+0

Oh oui, merci beaucoup! Ça marche! –

+0

Pas de problème! Ne pas oublier de cliquer sur la coche verte pour accepter la réponse est correcte. @ 赵 丹迪 – Lewis