![virtualenv gcc 错误 MySQL-python](https://linux22.com/image/566189/virtualenv%20gcc%20%E9%94%99%E8%AF%AF%20MySQL-python.png)
我正在尝试通过带有 virtualenv 的 PuTTY 安装 MySQL-python。
规格。
*CentOS-6.0
*Python2.6
所以我浏览了很多网站,我看到最多的是 python-dev 和 python-devel(顺便说一句,我不知道它们的区别)。我无法安装它们,我试过 Sudo、yum、easy_install 和 pip。我不是这台服务器的管理员,所以我无法执行 sudo 和 yum。我让管理员尝试将两者都安装到 python 的服务器 dist. 和我的虚拟环境中。两者都说无事可做。这是我尝试安装 MySQL-python-1.2.3 时收到的错误
_mysql.c:1928: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:1929: error: â_mysql_ConnectionObjectâ has no member named âconverterâ
_mysql.c:1938: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c: In function â_mysql_ConnectionObject_thread_idâ:
_mysql.c:1967: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:1969: warning: implicit declaration of function âmysql_thread_idâ
_mysql.c:1969: error: â_mysql_ConnectionObjectâ has no member named âconnectionâ
_mysql.c: In function â_mysql_ConnectionObject_use_resultâ:
_mysql.c:1989: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:1990: error: â_mysql_ConnectionObjectâ has no member named âconverterâ
_mysql.c:1999: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c: In function â_mysql_ConnectionObject_deallocâ:
_mysql.c:2017: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c: In function â_mysql_ConnectionObject_reprâ:
_mysql.c:2029: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:2031: error: â_mysql_ConnectionObjectâ has no member named âconnectionâ
_mysql.c: In function â_mysql_ResultObject_data_seekâ:
_mysql.c:2048: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:2049: warning: implicit declaration of function âmysql_data_seekâ
_mysql.c:2049: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c: In function â_mysql_ResultObject_row_seekâ:
_mysql.c:2062: error: âMYSQL_ROW_OFFSETâ undeclared (first use in this function)
_mysql.c:2062: error: expected â;â before ârâ
_mysql.c:2064: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:2065: error: â_mysql_ResultObjectâ has no member named âuseâ
_mysql.c:2070: error: ârâ undeclared (first use in this function)
_mysql.c:2070: warning: implicit declaration of function âmysql_row_tellâ
_mysql.c:2070: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c:2071: warning: implicit declaration of function âmysql_row_seekâ
_mysql.c:2071: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c: In function â_mysql_ResultObject_row_tellâ:
_mysql.c:2083: error: âMYSQL_ROW_OFFSETâ undeclared (first use in this function)
_mysql.c:2083: error: expected â;â before ârâ
_mysql.c:2085: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:2086: error: â_mysql_ResultObjectâ has no member named âuseâ
_mysql.c:2091: error: ârâ undeclared (first use in this function)
_mysql.c:2091: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c:2092: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c: In function â_mysql_ResultObject_deallocâ:
_mysql.c:2100: warning: implicit declaration of function âmysql_free_resultâ
_mysql.c:2100: error: â_mysql_ResultObjectâ has no member named âresultâ
_mysql.c: At top level:
_mysql.c:2331: error: â_mysql_ConnectionObjectâ has no member named âopenâ
_mysql.c:2338: error: â_mysql_ConnectionObjectâ has no member named âconverterâ
_mysql.c:2345: error: â_mysql_ConnectionObjectâ has no member named âconnectionâ
_mysql.c:2352: error: â_mysql_ConnectionObjectâ has no member named âconnectionâ
_mysql.c:2359: error: â_mysql_ConnectionObjectâ has no member named âconnectionâ
_mysql.c:2422: error: â_mysql_ResultObjectâ has no member named âconverterâ
_mysql.c:2422: error: initializer element is not constant
_mysql.c:2422: error: (near initialization for â_mysql_ResultObject_memberlist[0].offsetâ)
_mysql.c: In function â_mysql_ConnectionObject_getattrâ:
_mysql.c:2444: error: â_mysql_ConnectionObjectâ has no member named âopenâ
error: command 'gcc' failed with exit status 1
抱歉,我无法在 PuTTY 上获取整个错误
答案1
mysql-python 源中的 README 文件指出了先决条件:
- Python 2.3.4 或更高版本
- 安装工具
- MySQL 3.23.32 或更高版本(由于许多规定,我不会发布)
- mysql-开发
- mysql
- 库
- zlib-开发
- openssl
- 海湾合作委员会
因此,请尝试以下操作:
yum -y install mysql-devel mysql zlib zlib-devel openssl
然后尝试再次安装:
pip install mysql-python
(easy_install
贬值而赞成pip
,因此习惯使用它)
并且厚颜无耻地说:这是关于虚拟环境的简要介绍,以及更详细的介绍链接。查看一下activate
脚本,您会发现它只是将 ./bin/ 目录的路径添加到您的前面$PATH
,因此您只需将二进制文件的路径添加到前面即可寻址同一个 python 实例。