简体   繁体   English

如何在Mac OS X上安装wxPython?

[英]How do I install wxPython on Mac OS X?

I'd like to use wxPython on my Mac OS 10.7 (Lion) computer. 我想在我的Mac OS 10.7(Lion)计算机上使用wxPython。 (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. (我是Tkinter难民。)我从Python 2.7.1升级,然后下载并安装了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??? 这告诉我什么,我该怎么办呢?

Homebrew以完整的64位荣耀提供wxWidgets 2.9,包括wxWidgets。

brew install wxmac

I suggest: 我建议:

brew install wxpython

since wxpython installs wxmac, no need to install it seperately: 因为wxpython安装了wxmac,所以不需要单独安装它:

brew install wxmac
Warning: wxmac-3.0.2_2 already installed

What you probably want is a cocoa API based wxPython, then you don't have to worry about architecture. 您可能想要的是基于cocoa API的wxPython,那么您不必担心架构。

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 , 这是下载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 . 这是解释它的页面: http//wxpython.org/download.php

Use brew* to install wxmac using the following command. 使用brew *使用以下命令安装wxmac。

brew install --python wxmac --devel brew install --python wxmac --devel

once you install the wxmac create a symbolic link between the installed wx to the python library. 一旦你安装了wxmac,就在安装的wx和python库之间创建一个符号链接。

sudo ln -s /usr/local/Cellar/wxmac/2.9.4.0/lib/python2.7/site-packages/wx /Library/Python/2.7/site-packages/wx 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 )" *如果您之前没有安装Brew,请使用以下命令安装它:ruby -e“$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install )”

Make sure you are using the correct version of wxPython. 确保使用的是正确版本的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 不只是正确的Python版本,而是正确的版本二:32与64.这听起来很像这个主题: https//groups.google.com/forum/?fromgroups#!topic / wxpython- users / NQEY2SUC058

Mike's link is a great link to the answer, but just for completeness... Mike的链接是答案的绝佳链接,但仅仅是为了完整......

wxPython uses wxMac, which uses Carbon, which is limited to just 32 bit executables. wxPython使用wxMac,它使用Carbon,仅限于32位可执行文件。 However Python2.7(64bit) comes with a python-32 command. 但是Python2.7(64位)附带了一个python-32命令。

$ python-32
>> import wx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM