473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Installing MySQLdb under Cygwin

Hi,

I'm having trouble installing MySQLdb 0.9.2 on the following Cygwin system:
- Python 2.2.2
- MySQL 3.23.57
- gcc 2.95.3-10

The steps I take are:
1. Modify setup.py
- Set thread_safe_library = NO
- Change the Cygwin paths to use /cygdrive/c/...
- Change the library path to .../lib/opt

2. Run setup.py build
--> Errors on lines 2005-7 and 2094-6 of _mysql.c:
"Initializer element is not constant"

3. Replace the above lines with "0,"

4. Run setup.py build
--> Many undefined references to mysql functions

5. Change setup.py to use mysql library instead of mysqlclient

6. Run setup.py build
--> It compiles, so I run the setup.py install

7. When I try to import the library, I get the following error:
Traceback (most recent call last):
File "./test.py", line 4, in ?
import MySQLdb
File "MySQLdb/__init__.py", line 27, in ?
import _mysql
ImportError: dlopen: Win32 error 127

I'm stuck. I've tried using g++ instead of gcc, which gets rid of the
Initializer element is not constant" error. But I end up at the same error
when I try to import the module.

I have seen some posts from people who have managed to install MySQLdb on
Cygwin - could someone please let me know how to do it?

Kind regards,

Per
Jul 18 '05 #1
4 6433
Per,

On Fri, Oct 10, 2003 at 11:09:17AM -0700, Perflubron wrote:
7. When I try to import the library, I get the following error:
Traceback (most recent call last):
File "./test.py", line 4, in ?
import MySQLdb
File "MySQLdb/__init__.py", line 27, in ?
import _mysql
ImportError: dlopen: Win32 error 127
We have the following:

$ fgrep 127 /usr/include/w32api/winerror.h | head -1
#define ERROR_PROC_NOT_FOUND 127L

This error usually means the extension module did not export the init
function. What do you get when you try the following?

$ objdump -p _mysql.dll | fgrep init

For example:

$ objdump -p zlib.dll | fgrep init
[ 0] initzlib

If the init function is not being exported, then change the source from:

void
init_mysql(void)
{
...
}

to:

DL_EXPORT(void) /* for Python 2.2.2, use PyMODINIT_FUNC for Python 2.3+ */
init_mysql(void)
{
...
}
I have seen some posts from people who have managed to install MySQLdb
on Cygwin - could someone please let me know how to do it?


See the following mailing list thread:

http://cygwin.com/ml/cygwin/2003-10/msg00462.html

Try the Cygwin list if you need more help.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6

Jul 18 '05 #2
Hi Jason,
This error usually means the extension module did not export the init
function. What do you get when you try the following?

$ objdump -p _mysql.dll | fgrep init
I get:

ba58 52 mysql_init
[ 0] init_mysql__Fv

I don't know what the __Fv means.
If the init function is not being exported, then change the source from:

to:

DL_EXPORT(void) /* for Python 2.2.2, use PyMODINIT_FUNC for Python 2.3+ */
init_mysql(void)
{
...
}


The source already has the DL_EXPORT line in it.

I'll try the cygwin list now, thanks for your help.

Per
Jul 18 '05 #3
Per,

On Mon, Oct 13, 2003 at 01:53:48AM -0700, Perflubron wrote:
I get:

ba58 52 mysql_init
[ 0] init_mysql__Fv

I don't know what the __Fv means.


The "__Fv" is the name mangling produced by g++. Try again with gcc.
Or, add 'extern "C"' to the init function definition. What does objdump
indicate now?

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6

Jul 18 '05 #4
Hi Jason,
The "__Fv" is the name mangling produced by g++. Try again with gcc.
Or, add 'extern "C"' to the init function definition. What does objdump
indicate now?


g++ with extern "C" does not compile at first attempt. With gcc, I
overcame the "initializer element is not constant errors" by setting
the elements of the struct after creating it, e.g:

_mysql_ConnectionObject_Type.tp_alloc = &PyType_GenericAlloc;

But the objdump is still the same:
ba58 52 mysql_init
[ 0] init_mysql

I've given up on using MySQLdb under Cygwin. I instead installed the
Windows version of Python and MySQLdb, and will use that combination
for certain scripts.

Thanks for all your help!

Per
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dw | last post by:
Pehaba, does anyone knows how to install MySQLdb on cygwin? - test device: MySQLdb 0.9.2.0 targz + cygwin 1.5.7-cr-0x9e + python 2.3.3 on cygwin + mysql 4.0.17 win32 - modified setup.py's...
0
by: Bob Swerdlow | last post by:
I'm trying to install MySQLdb 0.9.2 so I can access my MySQL database from python under Solaris 8. I found the notes on changing the include and lib paths and it seems to find them okay, but when...
0
by: matthew collins | last post by:
hi all, trying to install mysqldb 1.0 and receiving a LOT of errors during the process. following the directions of by export mysqlversion="3.23.58" export mysqlclient="mysqlclient" export...
7
by: Matthias Verniers | last post by:
Hello Yesterday I installed Python 2.4. Since I often work with MySQL, I need the MySQLdb module, wich worked fine under 2.3. Now, it doesn't work under 2.4, it says it needs python 2.3 when I...
1
by: gmax2006 | last post by:
Hi, I am having hard time with installing MySQLdb on Linux. My Python version is 2.3. I have downloaded "MySQL-python-1.2.1_p2.tar.gz" from sourceforge. The README file asks for MySQL...
2
by: Sean O'Donnell | last post by:
Hi, I can't seem to get MySQLdb/1.2.1p2 to install on Slackware/10.2, with Python/2.4.1, and MySQL/5.0.18. The following command: $ python setup.py build 2setup.err returns the following...
0
by: Michael Boldin via alt email | last post by:
I installed python 2.5 and used the win package for installing MySQLdb. (Iam running Windows XP) Everything works as expected using python directly (Windows command shell) but using IDLE gives the...
0
by: martin.laloux | last post by:
search, search, search http://groups.google.be/group/comp.lang.python/browse_thread/thread/d75a491b8dbc3880/7d4f8eea29e23992?hl=fr&lnk=gst&q=MySQLdb+mac#7d4f8eea29e23992
3
by: dragrid | last post by:
Hi all Can anyone please help I am trying to install mysqldb module in python to interface with mysql on my desktop but I cannot find a clear instructions to do so I downloaded sourceforge.net...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.