Linux – virtualenv gcc error MySQL-python

djangolinuxMySQLpythonvirtualenv

I am trying to install MySQL-python through PuTTY with virtualenv.

Specs.
*CentOS-6.0
*Python2.6

So I have read many sites and the biggest thing I see is python-dev, and python-devel(btw I don't know the difference). I cannot get these to install, Sudo, yum, easy_install, and pip are what I have tried. I am not the admin of this server so sudo and yum I cannot perform. I had the admin try to install, both into, server dist. of python, and my virtualenv. Both say there is nothing to do. Here is the error I get when trying to install 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

Sorry I cannot get the whole error on PuTTY

Best Answer

The README file located within the source of mysql-python states the Prerequisites:

  • Python 2.3.4 or higher
  • setuptools
  • MySQL 3.23.32 or higher (with many stipulations I won't post)
  • mysql-devel
  • mysql
  • zlib
  • zlib-devel
  • openssl
  • gcc

So, try the following:

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

Then try to install again:

pip install mysql-python

(easy_install is depreciated in favor of pip, so get used to using that)

And shamelessly: here's a quick writeup on virtual environments and a link to a more thorough one. Take a look at the activate script, and you'll see it just prepends the path to the ./bin/ directory to your $PATH, so you can address the same python instance by simply pre-pending the path to the binary.

Related Topic