Python wx通过Homebrew

时间:2016-03-07 23:00:51

标签: python wxpython

我在Mac上安装Python wx时遇到问题。这就是我的所作所为:

brew install wxpython

给出了这个警告:

Caveats
Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
  mkdir -p /Users/snowcrash/Library/Python/2.7/lib/python/site-packages
  echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' 
  >> /Users/snowcrash/Library/Python/2.7/lib/python/site-packages/homebrew.pth

所以我按照建议从终端运行了2个命令:

mkdir -p /Users/snowcrash/Library/Python/2.7/lib/python/site-packages 
>> echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")'

但是当我尝试import wx时,我得到了:

>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/__init__.py", line 45, in <module>
    from wx._core import *
  File "/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core.py", line 4, in <module>
    import _core_
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core_.so, 2): no suitable image found.  Did find:
    /usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core_.so: mach-o, but wrong architecture

这似乎没有帮助:

How do I install wxPython on Mac OS X?

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

原来我必须这样做:

defaults write com.apple.versioner.python Prefer-32-Bit -bool no