lundi 21 avril 2014

python - ne peut pas importer wxPython (Mac) - Stack Overflow


I thought I'd move from using Tkinter to wxPython, but I'm having some troubles. All I get is this:


>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx

I have installed wxPython. When I run the uninstaller I clearly see that wxPython IS installed:


  1.  wxPython3.0-osx-cocoa-py2.7                 3.0.0.0

Enter the number of the install to examine or 'Q' to quit:

When I start Python I see that my version should match the version of 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.

I'm on OS X 10.7.5 32-bit.


Any help would be awesome! :)




Macs can have multiple versions of Python installed. Are you sure that you installed wxPython for the same python you invoke with the interpreter?


Try, which python, and make sure that this version of python has a wxredirect.pth file in site-packages pointing to the wxPython installation. (If it doesn't search for wxredirect.pth.)


Here's one version on my system...


> 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')

Here, btw, I can comment out lines in the wxredirect.pth to choose the version of wxPython I want to use.



I thought I'd move from using Tkinter to wxPython, but I'm having some troubles. All I get is this:


>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx

I have installed wxPython. When I run the uninstaller I clearly see that wxPython IS installed:


  1.  wxPython3.0-osx-cocoa-py2.7                 3.0.0.0

Enter the number of the install to examine or 'Q' to quit:

When I start Python I see that my version should match the version of 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.

I'm on OS X 10.7.5 32-bit.


Any help would be awesome! :)



Macs can have multiple versions of Python installed. Are you sure that you installed wxPython for the same python you invoke with the interpreter?


Try, which python, and make sure that this version of python has a wxredirect.pth file in site-packages pointing to the wxPython installation. (If it doesn't search for wxredirect.pth.)


Here's one version on my system...


> 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')

Here, btw, I can comment out lines in the wxredirect.pth to choose the version of wxPython I want to use.


0 commentaires:

Enregistrer un commentaire