无法在 Mac OS X 上导入 wx(Python)

发布于 2024-10-14 10:04:42 字数 1109 浏览 5 评论 0原文

这是我第一次在 mac 上使用 python。我从 python.org 安装了 Python 2.7.1,然后安装了 wxPython2.8-osx-unicode-py2.7

(Mac OS X 10.6.6)

我不知道它们安装到哪里,但无论如何,这就是我得到的:

Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34) 
[GCC 4.2.1 (Apple Inc. build 5664)] 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 "/usr/local/lib/wxPython-unicode-2.8.11.0/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.11.0/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.11.0/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.11.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core_.so: no matching architecture in universal wrapper
>>> 

It is first time I'm using python on mac. I installed Python 2.7.1 from python.org and then wxPython2.8-osx-unicode-py2.7

(Mac OS X 10.6.6)

I have no idea where they installed to, but anyway, that's what I get:

Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34) 
[GCC 4.2.1 (Apple Inc. build 5664)] 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 "/usr/local/lib/wxPython-unicode-2.8.11.0/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.11.0/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.11.0/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.11.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core_.so: no matching architecture in universal wrapper
>>> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相思碎 2024-10-21 10:04:42

正如 FogleBird 所说,wxPython 使用 32 位,Mac Python 安装程序应该提供两种架构。
因此,使用 32 位调用 python 应该可以让您毫无问题地使用它。
调用 32 位 Python

$ python2.7-32
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 "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> print wx.version()
2.8.12.1 (mac-unicode)

而不仅仅是 $ python

As FogleBird says, wxPython use 32-bit and Mac Python installer should offer both architectures.
So invoking python with 32 bit should allow you to use it with no issue.
to invoke Python in 32-bit

$ python2.7-32
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 "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> print wx.version()
2.8.12.1 (mac-unicode)

instead of just $ python

垂暮老矣 2024-10-21 10:04:42

您需要使用 32 位 Python 才能使用 wxPython。

这些二进制文件应该适用于所有
OSX 版本从 10.3.9 开始
PPC 或 i386 架构。
由于他们使用 Carbon API,所以他们
仅限于在 32 位模式下运行。

You need to use 32-bit Python to use wxPython.

These binaries should work on all
versions of OSX from 10.3.9 onwards on
either PPC or i386 architectures.
Since they use the Carbon API they are
limited to running in 32-bit mode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文