我想我应该从使用Tkinter转到wxPython,但我遇到了一些麻烦。我只知道这个:
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx我安装了wxPython。当我运行卸载程序时,我清楚地看到安装了wxPython:
1. wxPython3.0-osx-cocoa-py2.7 3.0.0.0
Enter the number of the install to examine or 'Q' to quit: 启动Python时,我看到我的版本应该与wxPython的版本相匹配:
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.我上的是OS 10.7.5 32位。
任何帮助都会很棒!:)
发布于 2014-02-19 04:33:32
Mac可以安装多个版本的Python。您确定您为与解释器调用的相同的python安装了wxPython吗?
尝试,which python,并确保这个版本的python在site-packages中有一个指向wxPython安装的wxredirect.pth文件。(如果它不搜索wxredirect.pth。)
我的系统里有一个版本..。
> which python2.6
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
> more /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/wxredirect.pth
import site; site.addsitedir('/usr/local/lib/wxPython-3.0.0.0/lib/python2.6')
#import site; site.addsitedir('/usr/local/lib/wxPython-2.9.1.1/lib/python2.6')
#import site; site.addsitedir('/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.6')在这里,顺便说一句,我可以在wxredirect.pth中注释掉行,以选择我想要使用的wxPython版本。
发布于 2017-06-29 03:06:52
我只是发现了同样的问题。我用brew install wxpython在mac上安装了它。我尝试了上面的方法,但没有用。当我安装另一个软件包时,我碰巧找到了解决方案,它显示在下面:
brew install tbb
Downloading https://homebrew.bintray.com/bottles/tbb-2017_U7.sierra.bottle.t
############################################################ 100.0%
==> Pouring tbb-2017_U7.sierra.bottle.tar.gz
==> 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/ningrongye/.local/lib/python2.7/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-
packages")' >> /Users/ningrongye/.local/lib/python2.7/site-
packages/homebrew.pth`这是自制的话,我只是尝试一下,而且效果很好。
宁荣
发布于 2019-03-29 18:25:59
我有Python2.7和3.7。在/usr/local/bin/中,有2.7和3.7Python版本的符号链接,也有pip的符号链接。
我在wxPython上安装了pip3
pip3 install -U wxPython然后,我检查了安装是否为Python3
myname$ python3
Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'4.0.4 osx-cocoa (phoenix) wxWidgets 3.0.5'安东尼奥
https://stackoverflow.com/questions/21864202
复制相似问题