Linux

virtualenv gcc 錯誤 MySQL-python

  • November 4, 2011

我正在嘗試通過 PuTTY 和 virtualenv 安裝 MySQL-python。

眼鏡。

*CentOS-6.0

*Python2.6

所以我已經閱讀了很多網站,我看到的最大的東西是 python-dev 和 python-devel(順便說一句,我不知道有什麼區別)。我無法安裝這些,Sudo、yum、easy_install 和 pip 是我嘗試過的。我不是這台伺服器的管理員,所以我無法執行 sudo 和 yum。我讓管理員嘗試將兩者都安裝到伺服器 dist 中。python和我的virtualenv。兩人都說無事可做。這是我在嘗試安裝 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 上得到整個錯誤

位於 mysql-python 源中的 README 文件說明了先決條件:

  • Python 2.3.4 或更高版本
  • 安裝工具
  • MySQL 3.23.32 或更高版本(有很多我不會發布的規定)
  • mysql-開發
  • mysql
  • zlib
  • zlib-開發
  • openssl
  • 海合會

因此,請嘗試以下操作:

yum -y install mysql-devel mysql zlib zlib-devel openssl

然後嘗試再次安裝:

pip install mysql-python

easy_install折舊有利於pip,所以習慣使用它)

厚顏無恥:這裡有一篇關於虛擬環境的快速文章和一個更詳盡的連結。看一下activate腳本,您會發現它只是將 ./bin/ 目錄的路徑添加到您$PATH的 .

引用自:https://serverfault.com/questions/327549