How do I install wxPython on Mac OS X?

廉价感情. 提交于 2019-12-17 18:33:09

问题


I'd like to use wxPython on my Mac OS 10.7 (Lion) computer. (I'm a Tkinter refugee.) I upgraded from Python 2.7.1, then downloaded and installed wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg. Here's what I get:

 Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
 [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
 Type "copyright", "credits" or "license()" for more information.
 >>> import wx
 Traceback (most recent call last):
   File "<pyshell#0>", line 1, in <module>
     import wx
   File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/__init__.py", line 45, in <module>
     from wx._core import *
   File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 4, in <module>
     import _core_
 ImportError: dlopen(/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core_.so, 2): no suitable image found.  Did find:
    /usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core_.so: no matching architecture in universal wrapper

What is this telling me, and what do I do about it???


回答1:


Homebrew provides wxWidgets 2.9 in full 64bit glory including wxWidgets.

brew install wxmac




回答2:


I suggest:

brew install wxpython

since wxpython installs wxmac, no need to install it seperately:

brew install wxmac
Warning: wxmac-3.0.2_2 already installed



回答3:


What you probably want is a cocoa API based wxPython, then you don't have to worry about architecture.

Here is a link to the download for wxPython 2.9: http://downloads.sourceforge.net/wxpython/wxPython2.9-osx-2.9.4.0-cocoa-py2.7.dmg,

and here is the page that explains it: http://wxpython.org/download.php.




回答4:


Use brew* to install wxmac using the following command.

brew install --python wxmac --devel

once you install the wxmac create a symbolic link between the installed wx to the python library.

sudo ln -s /usr/local/Cellar/wxmac/2.9.4.0/lib/python2.7/site-packages/wx /Library/Python/2.7/site-packages/wx

I Hope it will be helpful for future installers.

*if you do not have Brew installed prior, install it using the following command: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"




回答5:


Make sure you are using the correct version of wxPython. Not just the right Python version, but the right bit version two: 32 vs. 64. This sounds a lot like this thread: https://groups.google.com/forum/?fromgroups#!topic/wxpython-users/NQEY2SUC058




回答6:


Mike's link is a great link to the answer, but just for completeness...

wxPython uses wxMac, which uses Carbon, which is limited to just 32 bit executables. However Python2.7(64bit) comes with a python-32 command.

$ python-32
>> import wx


来源:https://stackoverflow.com/questions/9205317/how-do-i-install-wxpython-on-mac-os-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!