I am trying to create Python-3.2.0 virtual environment for upgrading my tool.
The tool was earlier built with 2.7.15 version. Now I want to upgrade it to Python-3.2.0
These are the steps which I followed on Cent-OS:
(a) Download the Python source code from the official repository
cd /tmp
wget https://www.python.org/ftp/python/3.2/Python-3.2.tgz
tar -xvf Python-3.2
cd Python-3.2
(b) Compile Python with the required flags
./configure --enable-optimizations --enable-shared --
prefix=/opt/python LDFLAGS=-Wl,-rpath=/opt/python/lib
sudo make install
I got the following errors:
/usr/bin/install -c python-config /opt/python/bin/python3.2m-config
rm python-config
LD_LIBRARY_PATH=/tmp/Python-3.2: ./python -E ./setup.py install \
--prefix=/opt/python \
--install-scripts=/opt/python/bin \
--install-platlib=/opt/python/lib/python3.2/lib-dynload \
--root=/
running install
running build
running build_ext
building dbm using ndbm
INFO: Can't locate Tcl/Tk libs and/or headers
building '_dbm' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_NDBM_H -IInclude -I/opt/python/include -I. -I./Include -I/usr/local/include -I/tmp/Python-3.2 -c /tmp/Python-3.2/Modules/_dbmmodule.c -o build/temp.linux-x86_64-3.2/tmp/Python-3.2/Modules/_dbmmodule.o
I n file included from Include/Python.h:111:0,
from /tmp/Python-3.2/Modules/_dbmmodule.c:6:
Include/modsupport.h:27:1: warning: ‘_PyArg_ParseTuple_SizeT’ is an unrecognized format function type [-Wformat=]
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
^
gcc -pthread -shared -Wl,-rpath=/opt/python/lib build/temp.linux-x86_64-3.2/tmp/Python-3.2/Modules/_dbmmodule.o -L. -L/opt/python/lib -L/usr/local/lib -lpython3.2m -o build/lib.linux-x86_64-3.2/_dbm.cpython-32m.so
*** WARNING: renaming "_dbm" since importing it failed: build/lib.linux-x86_64-3.2/_dbm.cpython-32m.so: undefined symbol: dbm_nextkey
Python build finished, but the necessary bits to build these modules were not found:
_tkinter bz2 ossaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_dbm
running build_scripts
copying and adjusting /tmp/Python-3.2/Tools/scripts/pydoc3 -> build/scripts-3.2
copying and adjusting /tmp/Python-3.2/Tools/scripts/idle3 -> build/scripts-3.2
copying and adjusting /tmp/Python-3.2/Tools/scripts/2to3 -> build/scripts-3.2
changing mode of build/scripts-3.2/pydoc3 from 644 to 755
I want to start by saying that what you're trying to do, is an exercise of futility. Check:
[Python]: PEP 373 -- Python 2.7 Release Schedule
[Python]: PEP 392 -- Python 3.2 Release Schedule
So:
You're trying to "upgrade" from a version that's going out of support at the end of the year (your particular flavor (v2.7.15) released last year) to a version that has been dead for several years
More: you're attempting v3.2.0 which is the very 1st one of that series
Quickly searching for your error revealed:
[Python.Bugs]: _dbm not building on Fedora 17
[Python.Bugs]: Failure to build _dbm with ndbm on Arch Linux
Now, this may or may not be the cause in your case. If it is, there is a fix, but you won't benefit from it because of #2..
A couple of ideas:
Generally, a software's 1st version of a series is likely to have more bugs, because it hasn't been tested much "in the real world" (as it hasn't been released yet). The chances of something going wrong increase if there is other software that is built on top of it (in this case, other Python 3rd-party modules). As an example (although not related to the current scenario), you could check [SO]: PyWin32 and Python 3.8.0
You should use a (Python) version that's supported and maintained (e.g. v3.8, or v3.7), so that you could have a real chance of getting help if running into problems
If for some reasons (that I fail to find logical) you need to stick to the v3.2, try at least using the latest one ([Python]: Python-3.2.6.tgz)
Related
I have an m1 mac with big surr.
I needed node v14 to run an old angular app. i had nodev16 ialraedy installed so i tried to install nvm . installed successfully and i have no problem installing any of the different versions of node v16 but when installing node 14.18.1 it is using python 3.9 for some weird reason.
I have installed python before is it by mistake using python 3.9 instead of 2.7
also i am searching internet and stack overflow and i read that node v14 cant be run on m1 mac is this true?
can someone please tell how to solve this error.
nvm install 14.18.1
Downloading and installing node v14.18.1...
Downloading https://nodejs.org/dist/v14.18.1/node-v14.18.1-darwin-arm64.tar.xz...
curl: (22) The requested URL returned error: 404
Binary download from https://nodejs.org/dist/v14.18.1/node-v14.18.1-darwin-arm64.tar.xz failed, trying source.
grep: /Users/rohitkrishnamoorthy/.nvm/.cache/bin/node-v14.18.1-darwin-arm64/node-v14.18.1-darwin-arm64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 8 CPU core(s)
Running with 7 threads to speed up the build
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: ${NVM_DIR}/.cache/src/node-v14.18.1/node-v14.18.1.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/src/node-v14.18.1/node-v14.18.1.tar.xz
$>./configure --prefix=/Users/rohitkrishnamoorthy/.nvm/versions/node/v14.18.1 <
Node.js configure: Found Python 3.9.6...
INFO: configure completed successfully
/Library/Developer/CommandLineTools/usr/bin/make -C out BUILDTYPE=Release V=0
touch /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/node_dtrace_header.stamp
touch /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/specialize_node_d.stamp
c++ -o /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/icuucx/deps/icu-small/source/common/uniset.o ../deps/icu-small/source/common/uniset.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DU_COMMON_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/common -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/.deps//Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/icuucx/deps/icu-small/source/common/uniset.o.d.raw -c
c++ -o /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/icuucx/deps/icu-small/source/common/dictbe.o ../deps/icu-small/source/common/dictbe.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DU_COMMON_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/common -O3 -gdwarf-2 -mmacosx-version-min=10.13 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/.deps//Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/icuucx/deps/icu-small/source/common/dictbe.o.d.raw -c
c++ -o /Users/rohitkrishnamoorthy/.nvm/.cache/src/node-v14.18.1/files/out/Release/obj.target/icuucx/deps/icu-small/source/common/chariter.o ../deps/icu-small/source/common/chariter.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DU_COMMON_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENA
You might need to uninstall python 3.9 and install Python 2.7.18.
Node 14.18.1 does work on m1 mac but if you update to Monterey 12.3, the pre-installed Python will be removed. So you might have to install it again.
I am trying to install sip as per the instructions here. I've installed Cygwin to allow me to use the make command in Windows (I'm using Windows 10). I run the configure.py file, and this creates a Makefile. I then run make from the Cygwin terminal, and all it does is print over and over again
make
make[####]: Entering directory 'cygdrive/c/Users/****/sip-4.19.13'
cd sipgen
Where #### keeps increasing with every iteration.
Any idea what's wrong here?
As you have not reported exactly how you did the things;
the following works for me:
$ wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.13/sip-4.19.13.tar.gz
....
2018-11-09 18:05:09 (149 KB/s) - ‘sip-4.19.13.tar.gz’ saved [1038815/1038815]
$ tar -xf sip-4.19.13.tar.gz
$ cd sip-4.19.13
$ python2 configure.py
This is SIP 4.19.13 for Python 2.7.14 on cygwin.
The SIP code generator will be installed in /usr/bin.
The sip.h header file will be installed in /usr/include/python2.7.
The sip module will be installed in /usr/lib/python2.7/site-packages.
The sip.pyi stub file will be installed in /usr/lib/python2.7/site-packages.
The default directory to install .sip files in is /usr/share/sip.
Creating sipconfig.py...
Creating top level Makefile...
Creating sip code generator Makefile...
Creating sip module Makefile...
$ make
make[1]: Entering directory '/cygdrive/d/cyg_pub/tmp/sip-4.19.13/sipgen'
gcc -c -pipe -O2 -Wall -W -DNDEBUG -I. -o main.o main.c
...
g++ -shared -o sip.dll siplib.o apiversions.o descriptors.o qtlib.o threads.o objmap.o voidptr.o array.o int_convertors.o bool.o -L/usr/lib/python2.7/config -lpython2.7
make[1]: Leaving directory '/cygdrive/d/cyg_pub/tmp/sip-4.19.13/siplib'
so what steps were different for you ?
I'm trying to convert a Python 3 script into C and then compile that C file into an executable.
I have this simple python script:
def greet(name = ""):
print("Hello {0}".format(name if len(name) > 0 else "World"))
greet("Mango")
I've converted this script into C using:
cython greet.py -o greet.c
Then I've compiled the C file using:
cc greet.c -o greet
After I entered the last command I got the error:
fatal error: Python.h: No such file or directory compilation terminated.
After I got the error I went back and realised that I was using Python3 and that I had forgot the "3" after "cython".
So re-compiled the python script using:
cython3 greet.py -o greet.c
Then attempted to re-compile the C file using:
cc greet.c -o greet
Again this failed and threw the same error so I went searching on SO and Google and found these questions:
fatal error: Python.h: No such file or directory
I have Python on my Ubuntu system, but gcc can't find Python.h
https://askubuntu.com/questions/526708/fatal-error-python-h-no-file-or-directory
None of these answers in these questions work.
I've made sure that I have installed cython all of the correct dependencies using apt-get install and pip install sadly thought it still does not seem to work.
Check the documentation. It's not enough to do gcc x.c -o x.
This page explains compilation: http://docs.cython.org/src/reference/compilation.html
There's a lot more to it, but a direct answer is:
Compiling your .c files will vary depending on your operating system. Python documentation for writing extension modules should have some details for your system. Here we give an example on a Linux system:
$ gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing
-I/usr/include/python2.7 -o yourmod.so yourmod.c
Of course in your situation it's going to be something closer to -I/usr/include/python3.4, or even $(pkg-config --libs --cflags python3). And you're not building with -shared, because you want an executable.
Shortest "this has to work" set of commands is:
cython3 --embed greet.py -o greet.c
gcc $(pkg-config --libs --cflags python3) greet.c -o greet
You need to install pkg-config if it's missing.
As #viraptor's answer shows you and as per my comment, your main problem is that you need to tell your C compiler (e.g. gcc) where to find the python headers required (pyconfig.h and Python.h). To do this, you need to pass a -I option to gcc.
The other answer suggests using pkg-config to add this to your command line. However, like you, with Ubuntu 14.04, cython3 and python3-dev installs, using this method leads the compiled program to exit with a segmentation fault for me.
So, I suggest you go back to basics. After
cython greet.py -o greet.c
Run the following command. It assumes that Python.h and friends are in the standard place (i.e. you've done a standard install of python3-dev)
gcc -I/usr/include/python3.4m -o greet greet.c -lpython3.4m
If that doesn't work - use find / -iname Python.h to find the location of the necessary files and alter the -I path accordingly.
In time, when you want to use cython on more complex programs, such as those that link to other C libraries, you'll need to learn about the other options you need to pass to gcc to get it to compile and link correctly. To get you going, though, the above should work (tested on Ubuntu 14.04 as per your spec)
P.S. I'm not sure why the pkg-config suggestion doesn't work - but for me it seems to add in an extra path to -I which breaks things.
Python 2:
python -m pip install --upgrade cython
Python 3:
python3 -m pip install --upgrade cython
I'd like to start by saying that asking a question here isn't something I do lightly. I've now been attempting to install Pygame 1.9.1 from source for four hours, and I've run into several problems but was able to overcome each one. This is the first one I'm completely stumped on.
After I unpack pygame-1.9.1release.tar.gz and cd to the folder, I run 'python3 setup.py install'
/Library/Frameworks/SDL.framework/Versions/Current/Headers/SDL_syswm.h:58:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
After some online research, I read that X11 is no longer included with OSX 10.9, so I installed XQuartz in the hope that it could serve as a replacement.
Xquartz does include 'Xlib.h', but it's filepath is /opt/X11/include/X11/Xlib.h, and the setup script doesn't find it here. I've tried several ways to fix this.
The error process specifically comes up in the build part of the install. I've tried using
python3 setup.py config --include-dirs /opt/X11/include
as well as
python3 setup.py config --include-dirs /opt/X11/include/X11
but get the same error.
I read online that installing the Xcode command line tools could fix this problem. I'm ~95% sure I had the command line tools before, but I tried to get them again anyway with 'xcode-select --install' only to be told that 'Can't install the software because it is currently unavailable from the Software Update server'. "No problem," I tell myself and just download the package from the Mac developers site. It doesn't help anything.
I've also tried symlinking with the command
sudo ln -s /usr/include/X11 /opt/X11/include/X11
Of everything I've tried, I understand this the least, do I could very well be doing the symlink command wrong.
Two other commands I tried are
export C_INCLUDE_PATH=/opt/X11/include
export CPLUS_INCLUDE_PATH=/opt/X11/include
Just looking at the documentation, I came across a debug option for the startup script.
The output of 'python3 setup.py build -g' is
running build
running build_py
running build_ext
building 'pygame.display' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -g -Ddarwin -I/Library/Frameworks/SDL.framework/Versions/Current/Headers -I/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c src/display.c -o build/temp.macosx-10.6-intel-3.3/src/display.o
In file included from src/display.c:30:
/Library/Frameworks/SDL.framework/Versions/Current/Headers/SDL_syswm.h:58:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
I'm not sure what else I can do, but I'd really appreciate some help with this. Thanks in advance!
setup.py build|install commands accepts CFLAGS and LDFLAGS compiler options, as far as I know.
Thus here, you can do
CFLAGS=-I/opt/X11/include python3 setup.py install
You probably need the LDFLAGS as well; I'm not sure about the exact location, but something like
CFLAGS=-I/opt/X11/include LDFLAGS=-L/opt/X11/lib python3 setup.py install
seems logical.
After that, you may have to set your DYLD_LIBRARY_PATH to point to your X11 libraries. In case your installation proceeds but your PyGame script won't run and complains about not finding X11 libraries. Thus
export DYLD_LIBRARY_PATH=/opt/X11/lib
As for the symbolic link you tried to create: it's the wrong way 'round: the two paths should have been switched, so I guess you got an error because /opt/X11/include/X11 already exists. But with the above, no symlink is necessary.
I ran into a similar error when trying to install pygame into my PyCharm project's virtualenv. I solved it by cding to the SDL Framework directory where the error originated and copying the X11 header files into it:
$ cd /Library/Frameworks/SDL.framework/Versions/Current/Headers
$ cp -R /opt/X11/include/X11 ./
then $ pip install pygame ran without errors.
i remember installing Python + Django + MySQL + MySQLdb on my 32-bit Mac with Leopard 10.5.7.
I tried the same procedure with Mac Snow Leopard. But have unfortunately ran into a lot of errors...
i dont know but something weird is happening. Please look at the error log:
Amit-Vermas-MacBook:mysql-python-1.2.2 amitverma$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-i386-2.5
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.3-i386-2.5/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:57,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyport.h:761:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:1050:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:721:1: warning: this is the location of the previous definition
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:1168:1: warning: "SIZEOF_LONG" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:811:1: warning: this is the location of the previous definition
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:1177:1: warning: "SIZEOF_PTHREAD_T" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:820:1: warning: this is the location of the previous definition
error: command 'gcc-4.0' failed with exit status 1
Amit-Vermas-MacBook:mysql-python-1.2.2 amitverma$
This is my personal makefile rule for that
MYSQLDB_VERSION=1.2.3c1
MYSQLDB_TARGET=$(BUILD_FLAGS_DIR)/mysqldb
MYSQLDB_PACKAGE=MySQL-python-$(MYSQLDB_VERSION).tar.gz
MYSQLDB_PACKAGE_URL=http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/$(MYSQLDB_VERSION)/$(MYSQLDB_PACKAGE)
.PHONY: mysqldb mysqldb-download
mysqldb: $(MYSQLDB_TARGET)
mysqldb-download: $(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)
$(MYSQLDB_TARGET): $(INIT_TARGET) $(MYSQLDB_DEPS) $(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)
-rm -rf $(UNPACK_DIR)/MySQL-python-$(MYSQLDB_VERSION)
tar -m -C $(UNPACK_DIR) -xzvf $(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)
-cd $(UNPACK_DIR)/MySQL-python-$(MYSQLDB_VERSION); \
for patch in $(PATCH_DIR)/mysqldb-$(MYSQLDB_VERSION)_$(ARCH)_*; \
do patch -p1 < $$patch; \
done
cd $(UNPACK_DIR)/MySQL-python-$(MYSQLDB_VERSION); export CC="gcc -m64" FC="g95 -m64" CPPFLAGS="-I$(RUNTIME_DIR)/include" CFLAGS="-m64 -I$(RUNTIME_DIR)/include" LD_LIBRARY_PATH=$(RUNTIME_DIR)/lib64:$(RUNTIME_DIR)/lib:$$LD_LIBRARY_PATH PATH=$(RUNTIME_DIR)/bin:$$PATH PYTHONPATH=$(RUNTIME_DIR)/lib/python2.5/site-packages/; $(RUNTIME_DIR)/bin/python2.5 setup.py install --prefix=$(RUNTIME_DIR)
touch $(MYSQLDB_TARGET)
$(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE):
for package in $(MYSQLDB_PACKAGE_URL); \
do \
echo -n "Downloading $$package... "; \
cd $(DOWNLOAD_DIR); curl -L -O $$package; \
echo "done"; \
done
touch $#
ALL_RUNTIME_TARGETS+=$(MYSQLDB_TARGET)
ALL_DOWNLOAD_TARGETS+=$(DOWNLOAD_DIR)/$(MYSQLDB_PACKAGE)
And a patch
$ more mysqldb-1.2.3c1_x86_64-apple-darwin10_patch-000
diff -Naur MySQL-python-1.2.3c1/setup.py MySQL-python-1.2.3c1.new/setup.py
--- MySQL-python-1.2.3c1/setup.py 2008-10-18 02:12:31.000000000 +0200
+++ MySQL-python-1.2.3c1.new/setup.py 2009-10-08 22:59:05.000000000 +0200
## -13,6 +13,8 ##
from setup_windows import get_config
metadata, options = get_config()
+options["extra_compile_args"].remove("-arch")
+options["extra_compile_args"].remove("x86_64")
metadata['ext_modules'] = [Extension(sources=['_mysql.c'], **options)]
metadata['long_description'] = metadata['long_description'].replace(r'\n', '')
setup(**metadata)
And it works for me. I cannot guarantee, but... maybe you will find some interesting hint inside.
Please note that I am using a custom built compiler (for outdated reasons too ugly to delve in)
The most likely explanation is that you are trying to link a 64-bit version of the MySQL libraries with a 32-bit-only version of Python (currently, all of the python.org installers for OS X are 32-bit only). (You can verify that by using the file command on the library files in /usr/local/mysql/).
Some solutions:
use the Apple-supplied python2.6 on
Snow Leopard which is 64-bit
install a 32-bit version of the MySQL libraries
install a complete solution using MacPorts: install the base MacPorts
infrastructure and then install the MySQLdb adapter for python 2.6 (or 2.5) which will also install all necessary dependencies including a new
python and MySQL client libraries that should all work together correctly (and be
able to be updated by MacPorts):
sudo port install py26-mysql # or py25-mysql
For using MySQL with python on OS X, I recommend the last solution, that is, unless you really enjoy and have the time to do package management and installation. It will likely save you a lot of trouble over the long run.
P.S. MacPorts includes ports of django and PIL as well:
sudo port install py26-django py26-pil
EDIT:
To go the MacPorts route, follow the instructions I gave here to remove the effects of a python.org installer python. DO NOT attempt to delete or modify the Apple-installed Python files in /usr/bin or /System/Library; they are part of OS X. Then follow the instructions cited above to install MacPorts. In order to avoid interference with Apple- or third-party installs, MacPorts installs all of its files into a completely separate directory structure rooted at /opt/local. Thus, you will need to modify your .bash_profile to add /opt/local/bin to your $PATH. If you want the MacPorts versions to be found first, add something like:
export PATH="/opt/local/bin:${PATH}"
When you start a new terminal session, you should find the MacPorts python2.6 at python2.6. If you also want to make the command python point there:
$ sudo port install python_select
$ sudo python_select -l
Available versions:
current none python26 python26-apple
$ sudo python_select python26
The following blog post helped me compile MySQLdb 1.2.2 on the Mac:
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
However, later on I tried MySQLDB 1.2.3c1 and didn't have any problems compiling out of the box. 1.2.2 is several years old and causes deprecation warnings on Python 2.6. I would just make the switch to 1.2.3.c1 and see if that works for you.
1.2.3c1 is the latest version on PyPi.
It looks like you need to reinstall/update XCode (build tools)