开发者

MySQLdb installed from pypm doesn't work with 32-bit python on Mac OSX

开发者 https://www.devze.com 2023-03-03 15:51 出处:网络
Before proceeding further, here are some details of my Mac and the installed python (ActivePython) and wxpython versions:

Before proceeding further, here are some details of my Mac and the installed python (ActivePython) and wxpython versions:

Mac version: 10.6.6 Python version: 2.7.1 (ActiveState Python) wxPython version: wxPython2.8-osx-unicode-py2.7

Here is a small code that I wrote to test:

#! /usr/bin/env arch -i386 /usr/local/bin/python

import time
import random
import re
import wx
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
import serial
import itertools
import datetime
import sys
import os
import MySQLdb

print "Hello World"

Here is the error that I got from running it:

Traceback (most recent call last):
  File "./sar.pyw", line 13, in <module>
    import MySQLdb
  File "/Users/ven/Library/Python/2.7/lib/python/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/Users/ven/Library/Python/2.7/lib/python/site-packages/_mysql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Users/ven/Library/Python/2.7/lib/python/site-packages/_mysql.so
  Expected in: flat namespace
 in /Users/ven/Library/Python/2.7/lib/python/site-packages/_mysql.so

As you can s开发者_如何转开发ee I am using 32-bit python in the shebang line because I need to work with wxpython which runs only on 32-bit. Now, the only package that has problem with the 32-bit python is the MySQLdb which has been installed using:

pypm install mysql-python

If I just removed the line

import MySQLdb
from the above piece of code, it runs perfectly and prints "Hello World".

If I removed "arch -i386" from the shebang line, the wxpython package doesn't work. I want to use both wxpython and MySQLdb at the same time. How do I do it?


Duplicate ;-)

This is a known bug -- the mysql-python package is built only for 64-bit at the moment.

I want to use both wxpython and MySQLdb at the same time. How do I do it?

wxPython 2.8 doesn't support 64-bit (due to using Carbon), this is why the PyPM package is built for only 32-bit. You could try using wxPython 2.9.

Workaround: remove wxpython using pypm (pypm uninstall wxpython), and then install the development cocoa binary wxPython2.9-osx-cocoa-py2.7 from wxpython.org.

0

精彩评论

暂无评论...
验证码 换一张
取 消