0

我有 Python 32 位,我安装了 MySQL 社区服务器 32 位,我正在尝试为 Python 安装 MySQLdb。我跑

easy_install mysql-python

我有这个错误

> easy_install mysql-python
Searching for mysql-python
Reading http://pypi.python.org/simple/mysql-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.4b5
Downloading http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.4b5.zip#md5=4f645ed23ea0f8848be77f25ffe94ade
Processing MySQL-python-1.2.4b5.zip
Running MySQL-python-1.2.4b5/setup.py -q bdist_egg --dist-dir /var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/egg-dist-tmp-GjLaFB
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Extracting in /var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/temp/tmpOVVY_R
Now working in /var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/temp/tmpOVVY_R/distribute-0.6.28
Building a Distribute egg in /private/var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5
/private/var/folders/ke/ke8HKCuzGB4LMCJ1eIAGqk+++TI/-Tmp-/easy_install-W_yT0e/MySQL-python-1.2.4b5/distribute-0.6.28-py2.6.egg
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1

关于为什么找不到 gcc-4.0 的任何想法?我安装了 Xcode 和 gcc 4.2.1。

4

2 回答 2

1

如果您在 Mountain Lion 上,您的问题似乎与没有安装 xcode 命令行工具有关,如果您首先从 xcode 安装它们,那么这应该可以

于 2012-10-27T10:57:58.823 回答
0

如何pip install mysql-pythonpython 2.7 为了>>>import MySQLdb

我遵循了所有这些步骤并且我得到了它的工作

对于 brew 以防它由于权限而不允许您更新。

chgrp -R admin /usr/local
chmod -R g+w /usr/local
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew

brew update
brew doctor  ## <--i did not use that
brew upgrade

ALSO I IGNORED THE Xcode update error

brew install mysql

pip install mysql-python

当我尝试导入 MySQLdb 时,它给我带来了一些错误,所以我遵循了下面链接提供的建议。

sudo ln -s /Users/$USERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib
sudo ln -s /Users/$USERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib

我使用的链接

库...问题

home bre更新权限问题

用brew安装mysql

于 2016-06-21T12:12:41.967 回答