File: MySQLdb-FAQ-1.html

package info (click to toggle)
python-mysqldb 0.9.1-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 364 kB
  • ctags: 712
  • sloc: ansic: 1,428; python: 1,098; makefile: 59; sh: 28
file content (80 lines) | stat: -rw-r--r-- 3,104 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE>MySQLdb FAQ: Compiling _mysql.so</TITLE>
 <LINK HREF="MySQLdb-FAQ-2.html" REL=next>

 <LINK HREF="MySQLdb-FAQ.html#toc1" REL=contents>
</HEAD>
<BODY>
<A HREF="MySQLdb-FAQ-2.html">Next</A>
Previous
<A HREF="MySQLdb-FAQ.html#toc1">Contents</A>
<HR>
<H2><A NAME="s1">1. Compiling <CODE>_mysql.so</CODE></A></H2>

<P>Here are some common errors that happen during the build.
This section covers UNIX/Linux problems only, as I don't do Windows.
<CODE>.so</CODE> is a dynamically loading library on Linux and most other UNIX
variants; a few use extensions other than <CODE>.so</CODE>. Windows probably
uses <CODE>.dll</CODE>.
<H2><A NAME="ss1.1">1.1 ImportError: libmysqlclient.so.6: cannot open shared object file:</A>
No such file or directory</H2>

<P>You have dynamic MySQL libraries, and by default, your compiler links
<CODE>_mysql.so</CODE> against these, but these are not on your loader path
when you start Python.
You have two basic options:
<P>
<OL>
<LI>Modify setup.py so that it links against the static library; see the comments.</LI>
<LI>If your linker supports a run-time loader path switch, you can set this
in setup.py as well. </LI>
<LI>Change your system environment so that the MySQL libraries are on
your loader path. With Linux, you can modify <CODE>/etc/ld.so.conf</CODE> (see
<CODE>man ldconfig</CODE> for more details) or you can add to or create the
<CODE>LD_LIBRARY_PATH</CODE> environment variable before starting Python, i.e.
<P>
<HR>
<PRE>
LD_LIBRARY_PATH=/path/to/mysql/libs python ... # Bourne-ish shell
</PRE>
<HR>
</LI>
</OL>
<H2><A NAME="ss1.2">1.2 ImportError: ./_mysql.so: undefined symbol: PyLong_FromUnsignedLongLong</A>
</H2>

<P><CODE>PyLong_FromUnsignedLongLong()</CODE> first appears in Python 1.5.2, so you are
linking against an earlier version. You may also have more than one version
installed. Get Python 1.5.2 or newer from your vendor or python.org.
<P>
<H2><A NAME="ss1.3">1.3 ImportError: ./_mysql.so: undefined symbol: uncompress</A>
</H2>

<P>It seems that MySQL-3.23 client libraries require libz for gzip
compression. setup.py should add this automatically.
<P>
<H2><A NAME="ss1.4">1.4 ./_mysql.c:33: mysql.h: No such file or directory</A>
</H2>

<P>The include path (-I) to your MySQL include files is wrong; modify
setup.py. OR: You don't have the MySQL development stuff loaded. If you
are using the Red Hat RPMs, you need the <CODE>MySQL-devel</CODE> RPM to compile
<CODE>_mysql.so</CODE>. However, if you link against the static MySQL
libraries (see above), you can install <CODE>_mysql.so</CODE> on a system
that does not have the MySQL client libraries (<CODE>libmysqlclient</CODE>).
<P>
<H2><A NAME="ss1.5">1.5 I'm using Windows...</A>
</H2>

<P>Say no more.
<P>I don't use Windows. setup.py is supposed to work for building.
There may also be a link to some user-contributed binaries on the web site.
<HR>
<A HREF="MySQLdb-FAQ-2.html">Next</A>
Previous
<A HREF="MySQLdb-FAQ.html#toc1">Contents</A>
</BODY>
</HTML>