Menu

RE: Solaris 9 and MySQLdb install

Help
Anonymous
2003-02-24
2012-09-19
  • Anonymous

    Anonymous - 2003-02-24

    I'm having problems trying to install MySQLdb on Solaris 9 sparc, I have the following setup:

    python 2.2
    MySQLdb-0.9.2
    mysql-3.23.43
    gcc version 2.95.3 20010315 (release)

    When I try to run python setup.py install, I get the following error:
    Reading specs from /opt/sfw/lib/gcc-lib/sparc-sun-solaris2.9/2.95.3/specs
    gcc version 2.95.3 20010315 (release)
    bash-2.05# python setup.py install
    running install
    running build
    running build_py
    not copying CompatMysqldb.py (output up-to-date)
    not copying _mysql_exceptions.py (output up-to-date)
    not copying MySQLdb/__init__.py (output up-to-date)
    not copying MySQLdb/converters.py (output up-to-date)
    not copying MySQLdb/connections.py (output up-to-date)
    not copying MySQLdb/cursors.py (output up-to-date)
    not copying MySQLdb/sets.py (output up-to-date)
    not copying MySQLdb/times.py (output up-to-date)
    not copying MySQLdb/constants/__init__.py (output up-to-date)
    not copying MySQLdb/constants/CR.py (output up-to-date)
    not copying MySQLdb/constants/FIELD_TYPE.py (output up-to-date)
    not copying MySQLdb/constants/ER.py (output up-to-date)
    not copying MySQLdb/constants/FLAG.py (output up-to-date)
    not copying MySQLdb/constants/REFRESH.py (output up-to-date)
    not copying MySQLdb/constants/CLIENT.py (output up-to-date)
    running build_ext
    building '_mysql' extension
    /export/builds/s9-release/s9_u0ccd_03/usr/src/tools/gcc -D_REENTRANT -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/sfw/mysql/include -I/opt/sfw/include/python2.2 -c _mysql.c -o build/temp.solaris-2.9-sun4u-2.2/_mysql.o -fPIC
    unable to execute /export/builds/s9-release/s9_u0ccd_03/usr/src/tools/gcc: No such file or directory
    error: command '/export/builds/s9-release/s9_u0ccd_03/usr/src/tools/gcc' failed with exit status 1

    I have tried changing setup.py for the library_dirs and include_dirs to put the path to mysql on my machine which is /opt/sfw/mysql and that did not seem to resolve the problem.
                                                                                       What seems bizarre above the error above is that it looks almost like it is trying to look for gcc under /export/builds.../gcc instead of /opt/sfw/bin which is where gcc is located on my machine.  Th fixes suggested for Solaris 7 do not seem to be applicable for my issue.

    Any help anyone can provide would be greatly appreciated.

    Thanks Mike

     
    • Anonymous

      Anonymous - 2003-02-27

      Hello, this is a post to my own post.  After fiddling around with setup.py I have gotten further then my previous post but still no cigar.

      I determined that at least one of my errors has to do with the fact that I had the wrong mysql include directory.  The actual mysql include directory should be /opt/sfw/mysql/include/mysql instead of just /opt/sfw/mysql/include.  Once I fixed this, things went a bit further but still no cigar.
      I get the error listed below:

      bash-2.05# python setup.py install
      running install
      running build
      running build_py
      not copying CompatMysqldb.py (output up-to-date)
      not copying _mysql_exceptions.py (output up-to-date)
      not copying MySQLdb/__init__.py (output up-to-date)
      not copying MySQLdb/converters.py (output up-to-date)
      not copying MySQLdb/connections.py (output up-to-date)
      not copying MySQLdb/cursors.py (output up-to-date)
      not copying MySQLdb/sets.py (output up-to-date)
      not copying MySQLdb/times.py (output up-to-date)
      not copying MySQLdb/constants/__init__.py (output up-to-date)
      not copying MySQLdb/constants/CR.py (output up-to-date)
      not copying MySQLdb/constants/FIELD_TYPE.py (output up-to-date)
      not copying MySQLdb/constants/ER.py (output up-to-date)
      not copying MySQLdb/constants/FLAG.py (output up-to-date)
      not copying MySQLdb/constants/REFRESH.py (output up-to-date)
      not copying MySQLdb/constants/CLIENT.py (output up-to-date)
      running build_ext
      building '_mysql' extension
      skipping _mysql.c (build/temp.solaris-2.9-sun4u-2.2/_mysql.o up-to-date)
      /export/builds/s9-release/s9_u0ccd_03/usr/src/tools/gcc -D_REENTRANT -shared build/temp.solaris-2.9-sun4u-2.2/_mysql.o -L/opt/sfw/mysql/lib -L/opt/sfw/mysql/lib -L/opt/sfw/mysql/lib -lmysqlclient_r -lz -o build/lib.solaris-2.9-sun4u-2.2/_mysql.so
      ld: fatal: library -lmysqlclient_r: not found
      ld: fatal: File processing errors. No output written to build/lib.solaris-2.9-sun4u-2.2/_mysql.so
      collect2: ld returned 1 exit status
      error: command '/export/builds/s9-release/s9_u0ccd_03/usr/src/tools/gcc' failed with exit status 1

      I seem to be much further ahead then I was with my last post but something is still wrong.  I am not sure where mysqlclient is supposed to be located on my system but I do not see anything called "mysqlclient or mysqlclient_r.  The setup.py file appears to be trying to use these as if they were libraries and lnking them to create _mysql.so.  If I do the following:

      gcc -D_REENTRANT -shared build/temp.solaris-2.9-sun4u-2.2/_mysql.o -L/opt/sfw/mysql/lib -L/opt/sfw/mysql/lib -L/opt/sfw/mysql/lib -lmysqlclient_r -lz -o build/lib.solaris-2.9-sun4u-2.2/_mysql.so

      and remove -lmysqlclient_r -lz from the command above the _mysql.so shared object library will be created and everything will appear to install.  Of course, it appears to install it incorrectly but the setup appears to complete and copies all the files for MySQLdb to /opt/sfw/lib/python2.2/site-packages.  So, if I can figure out what setup.py is trying to do with mysqlclient or where I get this library/package I should be able to install python.  I should note here that I installed mysql on my Solaris 9 using the Solaris optional software cdroms.  I did not install mysql from source.  I am wondering if possibly the source has some additional stuff that the Sun package does not?

       
    • Anonymous

      Anonymous - 2003-02-27

      Sorry to post yet again but I seem to have managed to get mysqldb installed without errors this time.  However, it still does not appear to be working. 

      I am trying to use mysqldb in a program and the program fails.  The program code appears below:
      import MySQLdb
      import MySQLdb.cursors
      conn = MySQLdb.Connect(
          host='localhost', user='root',
          passwd='', db='test',compress=1,
          cursorclass=MySQLdb.cursors.DictCursor) # <- important
      cursor = conn.cursor()
      cursor.execute("SELECT name, sometext txt FROM foo")
      rows = cursor.fetchall()
      cursor.close()
      conn.close()
      for row in rows:
          print row['name'], row['txt'] # bingo!
      # another (even better) way is:
      conn = MySQLdb.Connect(
          host='localhost', user='root',
          passwd='', db='test',compress=1)
      cursor = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
      # ...
      # results by field name
      cursor = conn.cursor()
      # ...
      # ...results by field number

      and the error appears below:
      Traceback (most recent call last):
        File "mysql.py", line 1, in ?
          import MySQLdb
        File "/opt/sfw/lib/python2.2/site-packages/MySQLdb/__init__.py", line 27, in ?
          import _mysql
      ImportError: ld.so.1: python: fatal: libmysqlclient.so.10: open failed: No such file or directory

      This error is bizarre to me because libmysqlclient.so.10 is located under /opt/sfw/mysql/lib/mysql ( the library directory for mysql that setup.py asks for).  My first impression of this error was that maybe my Sun Box doesn't know where to find the libraries.  I am unfortunately relatively new to Solaris so I wasn't sure how to do the linux equivalent of ldconfig and adding to /etc/ld.so.conf as I would have done on linux. 

      After reading around I determined that Solaris uses a command crle to perform the functions of ldconfig.  I tried addign the directories where I thought there might be libraries that couldn't be found to no avail.  I am now once again stuck and this time even worse then before as I have no idea where to go from here.  I am still not 100% positive that mysqldb is properly installed though it didn't give any errors and I didn't do anything out of the ordinary to install this time. 

      It's also possible that the program code above could be flawed as I am even newer to python then to Solaris, I am not sure that the code listed above is even correct.  I got it from a web site that seemed fairly legit so I am assuming the code is correct but it's possible it's not or that I copied it wrong.

      Any idea on what I can do to fix my problem would be greatly appreciated.

      Thank You,
      Mike

       
    • Anonymous

      Anonymous - 2003-02-27

      Sorry to post yet again but I seem to have managed to get mysqldb installed without errors this time.  However, it still does not appear to be working. 

      I am trying to use mysqldb in a program and the program fails.  The program code appears below:
      import MySQLdb
      import MySQLdb.cursors
      conn = MySQLdb.Connect(
          host='localhost', user='root',
          passwd='', db='test',compress=1,
          cursorclass=MySQLdb.cursors.DictCursor) # <- important
      cursor = conn.cursor()
      cursor.execute("SELECT name, sometext txt FROM foo")
      rows = cursor.fetchall()
      cursor.close()
      conn.close()
      for row in rows:
          print row['name'], row['txt'] # bingo!
      # another (even better) way is:
      conn = MySQLdb.Connect(
          host='localhost', user='root',
          passwd='', db='test',compress=1)
      cursor = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
      # ...
      # results by field name
      cursor = conn.cursor()
      # ...
      # ...results by field number

      and the error appears below:
      Traceback (most recent call last):
        File "mysql.py", line 1, in ?
          import MySQLdb
        File "/opt/sfw/lib/python2.2/site-packages/MySQLdb/__init__.py", line 27, in ?
          import _mysql
      ImportError: ld.so.1: python: fatal: libmysqlclient.so.10: open failed: No such file or directory

      This error is bizarre to me because libmysqlclient.so.10 is located under /opt/sfw/mysql/lib/mysql ( the library directory for mysql that setup.py asks for).  My first impression of this error was that maybe my Sun Box doesn't know where to find the libraries.  I am unfortunately relatively new to Solaris so I wasn't sure how to do the linux equivalent of ldconfig and adding to /etc/ld.so.conf as I would have done on linux. 

      After reading around I determined that Solaris uses a command crle to perform the functions of ldconfig.  I tried addign the directories where I thought there might be libraries that couldn't be found to no avail.  I am now once again stuck and this time even worse then before as I have no idea where to go from here.  I am still not 100% positive that mysqldb is properly installed though it didn't give any errors and I didn't do anything out of the ordinary to install this time. 

      It's also possible that the program code above could be flawed as I am even newer to python then to Solaris, I am not sure that the code listed above is even correct.  I got it from a web site that seemed fairly legit so I am assuming the code is correct but it's possible it's not or that I copied it wrong.

      Any idea on what I can do to fix my problem would be greatly appreciated.

      Thank You,
      Mike

       
      • Greg Fortune

        Greg Fortune - 2003-02-27

        I know absolutely nothing about Solaris, but I'll throw out a wild idea.  If Solaris has the equiv of ln (linking), then try linking the library into a standard library path.  The error you're seeing is almost certainly just because the module can't find the necessary .so file.

         
    • Anonymous

      Anonymous - 2003-03-01

      Well, I finally got Mysqldb working on Solaris 9 and thought I'd post a few tips here on what I did to resolve the problems I was having.  I notice that most information on these boards pertains to various versions of Linux but there are only a few references to Solaris.  The posts on this forum with regard to Solaris deal with Solaris 7 or 8 but not much info exists regarding Solaris 9.

      In any case, I came across a few different issues.  Firstly, the setup.py file requires that two fields be changed.  They are:
      include_dirs = [
          '/opt/sfw/mysql/include/mysql', '/opt/sfw/mysql/include/mysql',
          '/opt/sfw/mysql/include/mysql'
          ]
      library_dirs = [
          '/opt/sfw/mysql/lib/mysql', '/opt/sfw/mysql/lib/mysql',
          '/opt/sfw/mysql/lib/mysql'
          ]
      The default setup.py file uses /usr/local/mysql/include and /usr/local/mysql/lib for the include_dirs and library_dirs.  However, if you install MYSQL from the Solaris 9 Companion cdrom it seems to install mysql to /opt/sfw/mysql.  The include_dirs and library_dirs that should be used if you use mysql from the companion cdrom rather then compiling from source should be changed to /opt/sfw/mysql/include/mysql and /opt/sfw/mysql/lib/mysql respectively. 

      Additionally, if you also install gcc from the Solaris 9 cd's then you will also probably want to install gcc3.2.2 from www.sunfreeware.com.  Python 2.2 (the version I had installed ) requires the libraries from the newer version of gcc.  Also, I found that I had to use the crle command (the Solaris equivalent of ldconfig) in order to add the /opt/sfw/mysql/lib/mysql directory to the list of directories searched for shared libraries.  I kept getting complaints about not being able to find mysqlclient until I added /opt/sfw/mysql/lib/mysql using crle.

      Anyway, hope the info above helps any others who may be struggling to get this to work with Solaris 9.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.