سؤال

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 see 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?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top