【发布时间】:2011-08-20 03:05:39
【问题描述】:
在继续之前,这里是我的 Mac 和安装的 python (ActivePython) 和 wxpython 版本的一些细节:
Mac 版本:10.6.6 Python 版本:2.7.1(ActiveState Python) wxPython版本:wxPython2.8-osx-unicode-py2.7
这是我写的一个小代码来测试:
#! /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"
这是我运行它时遇到的错误:
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
如您所见,我在 shebang 行中使用 32 位 python,因为我需要使用仅在 32 位上运行的 wxpython。现在,唯一与 32 位 python 存在问题的软件包是 MySQLdb,它已使用以下方式安装:
pypm install mysql-python
如果我刚刚删除了该行
import MySQLdb从上面的代码中,它运行完美并打印“Hello World”。
如果我从 shebang 行中删除“arch -i386”,wxpython 包将不起作用。我想同时使用 wxpython 和 MySQLdb。我该怎么做?
【问题讨论】:
-
根据 www.wxpython.org 64 位版本的 wxpython 可用于 Mac。
标签: python macos wxpython mysql-python pypm