3

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

Nathan McAfee
  • 33
  • 1
  • 4
  • You are missing a dependency. Post the entire failure not just that generic line so that someone can determine which dependencies are needed by your instance of python for mysql-python to build. Update your question by using the `edit` link below your question. – brandeded Nov 03 '11 at 20:18

1 Answers1

2

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.

brandeded
  • 1,845
  • 8
  • 32
  • 50
  • Thanks in advance. One thing that confuses me, is this going to go into the virtualenv, or into main python site-packages. Like should I run `source ENV/bin/activate` before I install? If I do yum, I need admin permission anyway. – Nathan McAfee Nov 03 '11 at 20:39
  • Just updated the answer. The python packages can be installed "globally" (like system wide) or "locally" (in your virtual environment). Your virtual environment is just another path where a different python file structure lives (binaries, modules, etc). But using `yolk` and poking around a bit will help you better understand. Basically, if you created your virtualenv with the `--no-site-packages` argument, than you can not access site/global packages within your virtualenv. If you didn't, than they are accessible. Packages installed only within virtualenv aren't accessible out. – brandeded Nov 03 '11 at 20:43
  • That was it. I needed mysql-devel. I do not have root access to the server at work, so I had the admin do the install. I am obviously very new to this and I appreciate your help. btw, will you vote this question up? I think you have a very relevant answer to this. I found nothing that explained it so well. – Nathan McAfee Nov 05 '11 at 01:22
  • sure... also, re-reading your response... `yum` is a package manager, like software packages system wide... `-dev` or `-devel` or `lib*` packages contain libs/includes (source code) of things... so, for instance, `mysql-python` needs some of the source code files that `mysql-devel` has in it. I bet if you ran `yum whatprovides mysql.h` you might see the `mysql-devel` package listed. `yum` is like the software manager... the `eggs` are like little `python` programs/modules. this is where the scoping describe above applies. Not to `yum` manage packages. Hope that helps expand your knowledge. – brandeded Nov 05 '11 at 02:02
  • 1
    Wow, tremendously helpful thank you. Yeah, obviously I am very linux/python noob. And what you just said put so much into perspective. I wasn't sure why the differences between all these things and I am in a hurry to deploy this django site. I just wish more people would answer like you do, I always see question(ambiguous as they may be) explained at a level that the inquirer has no idea how to respond or move forward. One thing to remember; it's close to impossible to learn what you don't know you need to learn;) Thanks again! – Nathan McAfee Nov 07 '11 at 15:59