Menu

problems installing MySQL-python on OpenBSD

Help
Patrick M.
2006-10-27
2012-09-19
  • Patrick M.

    Patrick M. - 2006-10-27

    Hi all,

    I've been unable to successfully install MySQL-python on OpenBSD.

    Here are the details:

    versions:

    OpenBSD 3.9 stable
    Python 2.5
    MySQL 3.23.58
    MySQL-python-1.2.1_p2

    build results:

    % python setup.py build
    running build
    running build_py
    creating build
    creating build/lib.openbsd-3.9-i386-2.5
    copying _mysql_exceptions.py -> build/lib.openbsd-3.9-i386-2.5
    creating build/lib.openbsd-3.9-i386-2.5/MySQLdb
    copying MySQLdb/init.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    copying MySQLdb/converters.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    copying MySQLdb/connections.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    copying MySQLdb/release.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    copying MySQLdb/times.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    creating build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/init.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/CR.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/ER.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py ->
    build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.openbsd-3.9-i386-2.5
    gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC
    -I/usr/local/include/mysql -I/usr/local/include/python2.5 -c _mysql.c -o
    build/temp.openbsd-3.9-i386-2.5/_mysql.o
    -Dversion_info="(1,2,1,'final',2)" -Dversion="1.2.1_p2"
    _mysql.c: In function _mysql_server_init': _mysql.c:222: warning: unused variables'
    _mysql.c:223: warning: unused variable cmd_argc' _mysql.c:223: warning: unused variablei'
    _mysql.c:223: warning: unused variable groupc' _mysql.c:224: warning: unused variableitem'
    _mysql.c:298: warning: label finish' defined but not used _mysql.c: In function_mysql_escape_dict':
    _mysql.c:1132: warning: passing arg 2 of `PyDict_Next' from incompatible
    pointer type
    gcc -shared -fPIC build/temp.openbsd-3.9-i386-2.5/_mysql.o
    -L/usr/local/lib/mysql -lmysqlclient -lz -lm -o
    build/lib.openbsd-3.9-i386-2.5/_mysql.so

    install results:

    [root]# python setup.py install
    running install
    running build
    running build_py
    copying MySQLdb/release.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
    running build_ext
    running install_lib
    copying build/lib.openbsd-3.9-i386-2.5/_mysql_exceptions.py ->
    /usr/local/lib/python2.5/site-packages
    creating /usr/local/lib/python2.5/site-packages/MySQLdb
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/init.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/converters.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/connections.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/cursors.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/release.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/times.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb
    creating /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/init.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/CR.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/FIELD_TYPE.py
    -> /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/ER.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/FLAG.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/REFRESH.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants/CLIENT.py ->
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants
    copying build/lib.openbsd-3.9-i386-2.5/_mysql.so ->
    /usr/local/lib/python2.5/site-packages
    byte-compiling
    /usr/local/lib/python2.5/site-packages/_mysql_exceptions.py to
    _mysql_exceptions.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/init.py to
    init.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/converters.py to
    converters.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/connections.py to
    connections.pyc
    byte-compiling /usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py
    to cursors.pyc
    byte-compiling /usr/local/lib/python2.5/site-packages/MySQLdb/release.py
    to release.pyc
    byte-compiling /usr/local/lib/python2.5/site-packages/MySQLdb/times.py
    to times.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/init.py to
    init.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/CR.py to CR.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/FIELD_TYPE.py
    to FIELD_TYPE.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/ER.py to ER.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/FLAG.py to
    FLAG.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/REFRESH.py to
    REFRESH.pyc
    byte-compiling
    /usr/local/lib/python2.5/site-packages/MySQLdb/constants/CLIENT.py to
    CLIENT.pyc
    running install_egg_info
    Writing
    /usr/local/lib/python2.5/site-packages/MySQL_python-1.2.1_p2-py2.5.egg-info

    test program db.py:

    !/usr/local/bin/python

    import MySQLdb
    conn = MySQLdb.connect(db = 'xxxx', host = 'localhost', user = 'xxxx',
    passwd = 'xxxx')

    results of running db.py

    % ./db.py
    Traceback (most recent call last):
    File "./db.py", line 3, in <module>
    import MySQLdb
    File "/usr/local/lib/python2.5/site-packages/MySQLdb/init.py",
    line 19, in <module>
    import _mysql
    ImportError: Cannot load specified object

     
    • Patrick M.

      Patrick M. - 2006-10-29

      I have a 32-bit system that I bought 1.5 years ago. The processor is a Celeron 320 2.4G with 256K 533Mhz cache.

       
    • Andy Dustman

      Andy Dustman - 2006-10-27

      Try 1.2.2b2 which is the first version with some Python-2.5 support. If it still doesn't work, post the build results only.

       
    • Patrick M.

      Patrick M. - 2006-10-27

      OK, I installed 1.2.2b2 and got the same error as before when running db.py.

      Here are the build results:

      % python setup.py build
      running build
      running build_py
      creating build
      creating build/lib.openbsd-3.9-i386-2.5
      copying _mysql_exceptions.py -> build/lib.openbsd-3.9-i386-2.5
      creating build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/init.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/converters.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/connections.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/release.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/times.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      creating build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/init.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/REFRESH.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      running build_ext
      building '_mysql' extension
      creating build/temp.openbsd-3.9-i386-2.5
      gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/mysql -I/usr/local/include/python2.5 -c _mysql.c -o build/temp.openbsd-3.9-i386-2.5/_mysql.o -Dversion_info=(1,2,2,'beta',2) -Dversion=1.2.2b2
      _mysql.c: In function _mysql_server_init': _mysql.c:234: warning: unused variables'
      _mysql.c:235: warning: unused variable cmd_argc' _mysql.c:235: warning: unused variablei'
      _mysql.c:235: warning: unused variable groupc' _mysql.c:236: warning: unused variableitem'
      _mysql.c:310: warning: label finish' defined but not used _mysql.c: In function_mysql_escape_dict':
      _mysql.c:1144: warning: passing arg 2 of `PyDict_Next' from incompatible pointer type
      gcc -shared -fPIC build/temp.openbsd-3.9-i386-2.5/_mysql.o -L/usr/local/lib/mysql -lmysqlclient -lz -lm -o build/lib.openbsd-3.9-i386-2.5/_mysql.so

       
      • Andy Dustman

        Andy Dustman - 2006-10-27

        Edit line 1135 of _mysql.c and change it from:

            int ppos = 0;
        

        to:

            Py_ssize_t ppos = 0;
        

        Rebuild and reinstall.

        The warnings around line 234 are just that -- warnings -- and only happen when using MySQL older than 4.0, but aren't harmful. 4.0 is the oldest version I am supporting right now.

        I've also checked in this change on the MySQLdb-1.2 branch so it will be in 1.2.2b3 or later. That may well be the only thing that needed to be fixed for Python-2.5, which is due to an API change and only affects 64-bit platforms, or so I thought.

         
    • Patrick M.

      Patrick M. - 2006-10-28

      I changed line 1135 in _mysql.c as you indicated and rebuilt and reinstalled. I didn't get the 'incompatible pointer type' error when I rebuilt, but it still didn't work. I got the same error as before when I ran my test script.

      Am I supposed to end up with a file named '_mysql' in directory /usr/local/lib/python2.5/site-packages? There isn't a file by that name there; what's there is a file named '_mysql.so'. And the file mentioned in the runtime error message is /usr/local/lib/python2.5/site-packages/MySQLdb/init.py, one directory deeper than the _mysql.so file.

      I haven't updated MySQL on my machine. It's still version 3.23.58. Your message seemed to imply that that version should work even though you aren't officially supporting it.

      Anyway, here's the latest build output:

      % python setup.py build
      running build
      running build_py
      creating build
      creating build/lib.openbsd-3.9-i386-2.5
      copying _mysql_exceptions.py -> build/lib.openbsd-3.9-i386-2.5
      creating build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/init.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/converters.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/connections.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/release.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      copying MySQLdb/times.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb
      creating build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/init.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/REFRESH.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.openbsd-3.9-i386-2.5/MySQLdb/constants
      running build_ext
      building '_mysql' extension
      creating build/temp.openbsd-3.9-i386-2.5
      gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/mysql -I/usr/local/include/python2.5 -c _mysql.c -o build/temp.openbsd-3.9-i386-2.5/_mysql.o -Dversion_info=(1,2,2,'beta',2) -Dversion=1.2.2b2
      _mysql.c: In function _mysql_server_init': _mysql.c:234: warning: unused variables'
      _mysql.c:235: warning: unused variable cmd_argc' _mysql.c:235: warning: unused variablei'
      _mysql.c:235: warning: unused variable groupc' _mysql.c:236: warning: unused variableitem'
      _mysql.c:310: warning: label `finish' defined but not used
      gcc -shared -fPIC build/temp.openbsd-3.9-i386-2.5/_mysql.o -L/usr/local/lib/mysql -lmysqlclient -lz -lm -o build/lib.openbsd-3.9-i386-2.5/_mysql.so

       
      • Andy Dustman

        Andy Dustman - 2006-10-28

        _mysql.so is what you should have a on POSIX platform (*bsd, Linux, UNIX, Solaris, Mac OS X).

        What happens when you run (from some directory other than the MySQL-python source directory; it will skew the results):

        $ python -v
        >>> import MySQLdb

        (include only output after the import statement) You should see something like this (with /usr/local/lib/python2.5 instead of /usr/lib/python2.4):

        import MySQLdb # directory /usr/lib/python2.4/site-packages/MySQLdb

        /usr/lib/python2.4/site-packages/MySQLdb/init.pyc matches /usr/lib/python2.4/site-packages/MySQLdb/init.py

        import MySQLdb # precompiled from /usr/lib/python2.4/site-packages/MySQLdb/init.pyc

        /usr/lib/python2.4/site-packages/MySQLdb/release.pyc matches /usr/lib/python2.4/site-packages/MySQLdb/release.py

        import MySQLdb.release # precompiled from /usr/lib/python2.4/site-packages/MySQLdb/release.pyc
        dlopen("/usr/lib/python2.4/site-packages/_mysql.so", 2);

        /usr/lib/python2.4/site-packages/_mysql_exceptions.pyc matches /usr/lib/python2.4/site-packages/_mysql_exceptions.py

        import _mysql_exceptions # precompiled from /usr/lib/python2.4/site-packages/_mysql_exceptions.pyc
        import _mysql # dynamically loaded from /usr/lib/python2.4/site-packages/_mysql.so
        ....

         
    • Patrick M.

      Patrick M. - 2006-10-28

      Andy,

      Here's the output after the import statement:

      import MySQLdb # directory /usr/local/lib/python2.5/site-packages/MySQLdb

      /usr/local/lib/python2.5/site-packages/MySQLdb/init.pyc matches /usr/local/lib/python2.5/site-packages/MySQLdb/init.py

      import MySQLdb # precompiled from /usr/local/lib/python2.5/site-packages/MySQLdb/init.pyc

      /usr/local/lib/python2.5/site-packages/MySQLdb/release.pyc matches /usr/local/lib/python2.5/site-packages/MySQLdb/release.py

      import MySQLdb.release # precompiled from /usr/local/lib/python2.5/site-packages/MySQLdb/release.pyc
      dlopen("/usr/local/lib/python2.5/site-packages/_mysql.so", 2);
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.5/site-packages/MySQLdb/init.py", line 19, in <module>
      import _mysql
      ImportError: Cannot load specified object

       
      • Andy Dustman

        Andy Dustman - 2006-10-29

        Run:

        ldd /usr/local/lib/python2.5/site-packages/_mysql.so

        The output should be similar to this:

            linux-gate.so.1 =&gt;  (0xffffe000)
            libmysqlclient_r.so.15 =&gt; /usr/lib/libmysqlclient_r.so.15 (0xb7da3000)
            libpthread.so.0 =&gt; /lib/tls/i686/cmov/libpthread.so.0 (0xb7d90000)
            libc.so.6 =&gt; /lib/tls/i686/cmov/libc.so.6 (0xb7c5b000)
            libcrypt.so.1 =&gt; /lib/tls/i686/cmov/libcrypt.so.1 (0xb7c2d000)
            libnsl.so.1 =&gt; /lib/tls/i686/cmov/libnsl.so.1 (0xb7c17000)
            libm.so.6 =&gt; /lib/tls/i686/cmov/libm.so.6 (0xb7bf1000)
            libz.so.1 =&gt; /usr/lib/libz.so.1 (0xb7bdd000)
            /lib/ld-linux.so.2 (0x80000000)
        

        You won't have the various Linux-related things; that's OK. And the addresses are not important. But if you get some libraries listed as "not found", then your loader path is incomplete. On Linux you would edit /etc/ld.so.conf and add any missing paths and then run ldconfig.

         
    • Patrick M.

      Patrick M. - 2006-10-29

      Here's the output from running ldd:

      /usr/local/lib/python2.5/site-packages/_mysql.so:
      /usr/local/lib/python2.5/site-packages/_mysql.so: Exec format error
      /usr/local/lib/python2.5/site-packages/_mysql.so: exit status 1

       
      • Andy Dustman

        Andy Dustman - 2006-10-29

        Do you actually have a 32-bit or 64-bit system? All your stuff was compiling as i386 but yet you needed the Py_ssize_t fix which is only supposed to be needed in i386-64. I'm wondering if you have a mix of 32-bit and 64-bit packages.

         

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.