2

如果我在创建 virtualenv 时使用 --no-site-packages 选项,然后尝试安装 MySQL-python,我得到:

error: command 'gcc' failed with exit status 1

以下是我遵循的步骤:

easy_install-2.7 --install-dir ~/src/lib/ virtualenv==dev
~/src/lib/virtualenv  --no-site-packages ENV
.../ENV/bin/pip-2.7 install MySQL-python

我还尝试下载 mySQL-python 并使用

.../ENV/bin/python setup.py build

我得到同样的错误枯萎方式。我假设我错过了这个 virtualenv 中的 gcc,但是如何在仍然使用 --no-site-packages 选项的同时将它安装在这个 virtualenv 中。谢谢

编辑:根据下面的评论,这里是整个错误输出。

running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc -m32 -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/opt/lampp/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
In file included from /opt/lampp/include/python2.7/Python.h:58,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/opt/lampp/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
In file included from /usr/include/mysql/my_config.h:11,
                 from _mysql.c:36:
/usr/include/mysql/my_config_x86_64.h:1032:1: warning: "SIZEOF_LONG" redefined
In file included from /opt/lampp/include/python2.7/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/opt/lampp/include/python2.7/pyconfig.h:989:1: warning: this is the location of the previous definition
error: command 'gcc' failed with exit status 1
4

2 回答 2

1

你需要 mysql-devel 包。要安装,您需要指定实际的包名称 -

sudo apt-get install libmysql++-dev
于 2011-06-20T01:42:14.503 回答
0

您是否尝试过使用 sudo 命令。我猜你有权限问题而不是这里的任何其他问题。通常安装会引发此错误,因为它试图访问具有您不拥有的 root 权限的目录。

于 2011-04-23T16:48:39.770 回答