未找到wxmac映像(Python 2.7.5, OS X)

时间:2022-09-18 23:06:42

I had "brew installed" wxmac back in 2012. Recently, I "brew upgraded" and then "cleaned up". Since then, I can no longer import wx:

早在2012年,我就“安装了brew”wxmac。最近,我“酿造升级”,然后“净化”。从那时起,我再也不能进口wx:

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/wx-2.9.4-osx_cocoa/wx/__init__.py", line 45, in <module>
    from wx._core import *
  File "/Library/Python/2.7/site-packages/wx-2.9.4-osx_cocoa/wx/_core.py", line 4, in <module>
    import _core_
ImportError: dlopen(/Library/Python/2.7/site-packages/wx-2.9.4-osx_cocoa/wx/_core_.so, 2): Library not loaded: /opt/local/lib/libwx_osx_cocoau_xrc-2.9.4.0.0.dylib
  Referenced from: /Library/Python/2.7/site-packages/wx-2.9.4-osx_cocoa/wx/_core_.so
  Reason: image not found

Looks like I now have a version newer than 2.9.4:

看起来我现在有一个比2.9.4更新的版本:

brew install wxmac
Warning: wxmac-3.0.1 already installed

Looking at my Python installation, these are the relevant files:

看看我的Python安装,以下是相关的文件:

ls /Library/Python/2.7/site-packages/
wx
wx-2.9.4-osx_cocoa
wx.pth
wxPython_common-2.9.4.0-py2.7.egg-info
wxversion.py
wxversion.pyc

I'm suspecting that "brew cleanup" removed my older, but working, version of wxmac. Now, either the wxmac version or some symlink is causing the current problem. How should I go about fixing or figuring it out?

我怀疑“brew cleanup”删除了我的旧的,但工作的版本的wxmac。现在,要么是wxmac版本,要么是某个symlink导致了当前的问题。我该如何着手修复或解决它?

1 个解决方案

#1


1  

It looks like wxpython files were copied from or symlinked to or just referenced from /Library; Homebrew will never install files to /Library and doesn't know how to manage them if you or an installer placed them there. To use Homebrew wxpython, please remove everything wx-related from your /Library site-packages folder and brew install wxpython in addition to wxmac.

看起来wxpython文件是从/Library中复制的,或与/ symlinked to或仅仅引用的;Homebrew不会将文件安装到/库中,并且如果您或安装人员将文件放置在那里,也不知道如何管理它们。要使用Homebrew wxpython,请从/Library站点包文件夹中删除与wx相关的所有内容,并在wxmac之外安装wxpython。

To use wxpython with system Python, you need to tell Python that your Homebrew site-packages folder is a special "site-packages" folder; having it in sys.path is not enough, because wxpython relies on .pth files that are only processed in special folders. To do this, you can run:

要在系统Python中使用wxpython,需要告诉Python自制站点包文件夹是一个特殊的“站点包”文件夹;在系统。路径是不够的,因为wxpython依赖于仅在特殊文件夹中处理的.pth文件。要做到这一点,你可以这样做:

mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo "import site; site.addsitedir('$(brew --prefix)/lib/python2.7/site-packages')" >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth

Then, import wx should work.

然后,导入wx应该可以工作。

#1


1  

It looks like wxpython files were copied from or symlinked to or just referenced from /Library; Homebrew will never install files to /Library and doesn't know how to manage them if you or an installer placed them there. To use Homebrew wxpython, please remove everything wx-related from your /Library site-packages folder and brew install wxpython in addition to wxmac.

看起来wxpython文件是从/Library中复制的,或与/ symlinked to或仅仅引用的;Homebrew不会将文件安装到/库中,并且如果您或安装人员将文件放置在那里,也不知道如何管理它们。要使用Homebrew wxpython,请从/Library站点包文件夹中删除与wx相关的所有内容,并在wxmac之外安装wxpython。

To use wxpython with system Python, you need to tell Python that your Homebrew site-packages folder is a special "site-packages" folder; having it in sys.path is not enough, because wxpython relies on .pth files that are only processed in special folders. To do this, you can run:

要在系统Python中使用wxpython,需要告诉Python自制站点包文件夹是一个特殊的“站点包”文件夹;在系统。路径是不够的,因为wxpython依赖于仅在特殊文件夹中处理的.pth文件。要做到这一点,你可以这样做:

mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo "import site; site.addsitedir('$(brew --prefix)/lib/python2.7/site-packages')" >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth

Then, import wx should work.

然后,导入wx应该可以工作。