简体   繁体   English

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

[英]wxmac image not found (Python 2.7.5, OS X)

I had "brew installed" wxmac back in 2012. Recently, I "brew upgraded" and then "cleaned up". 我在2012年“酿造”了wxmac 。最近,我“酿造了升级”,然后“清理了”。 Since then, I can no longer import wx: 从那时起,我不再可以导入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. 我怀疑“ brew cleanup”删除了我的较旧但可以正常工作的wxmac版本。 Now, either the wxmac version or some symlink is causing the current problem. 现在,wxmac版本或某些符号链接都导致当前问题。 How should I go about fixing or figuring it out? 我应该如何解决或解决它?

It looks like wxpython files were copied from or symlinked to or just referenced from /Library; 看来wxpython文件是从/ Library复制或符号链接到或刚刚从/ Library引用的; Homebrew will never install files to /Library and doesn't know how to manage them if you or an installer placed them there. Homebrew永远不会将文件安装到/ Library,并且如果您或安装程序将文件放置在/ Library中,也不知道如何管理它们。 To use Homebrew wxpython, please remove everything wx-related from your /Library site-packages folder and brew install wxpython in addition to wxmac . 要使用Homebrew wxpython,请从/ Library site-packages文件夹中删除所有与wx相关的内容,并除了wxmac brew install wxpython ,还brew install wxpython wxmac

To use wxpython with system Python, you need to tell Python that your Homebrew site-packages folder is a special "site-packages" folder; 要将wxpython与系统Python一起使用,您需要告诉Python您的Homebrew site-packages文件夹是一个特殊的“ site-packages”文件夹; having it in sys.path is not enough, because wxpython relies on .pth files that are only processed in special folders. 在sys.path中拥有它是不够的,因为wxpython依赖于仅在特殊文件夹中处理的.pth文件。 To do this, you can run: 为此,您可以运行:

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. 然后, import wx应该起作用。

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

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