How to install wxversion for Python

2019-02-28 15:15发布

问题:

I'm experimenting with the "SPy" Spectral Python library, using PyCharm, and I've gotten to the point where it tells me that wxversion was not found. How can I install wxversion?

I'm very new to Python in general, so am I doing something else wrong? Here is my code:

import matplotlib
#matplotlib.use('WX')    #Replaced by editing matplotlibrc
from spectral import *

img = open_image('92AV3C.lan')
print img.__class__
print
print img
print
print img.shape
pixel = img[50,100]
print
print pixel.shape
band6 = img[:,:,5]
print
print band6.shape
print


arr = img.load() 
print arr.__class__
print
print arr.info()
print
print arr.shape

view = imshow(img, (29, 19, 9))

All of which is from the SPy guide here: http://www.spectralpython.net/user_guide.html

Here is the error:

Traceback (most recent call last):
  File "/Users/pkillam/PycharmProjects/untitled/SPy Experiments", line 36, in <module>
  File "/Library/Python/2.7/site-packages/spectral/graphics/spypylab.py", line 1238, in imshow
    import matplotlib.pyplot as plt
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backends/backend_wxagg.py", line 6, in <module>
    import backend_wx    # already uses wxversion.ensureMinimal('2.8')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backends/backend_wx.py", line 53, in <module>
    raise ImportError(missingwxversion)
ImportError: Matplotlib backend_wx and backend_wxagg require wxversion, which was not found.

Also, are there any other guides/tutorials out there for SPy?

回答1:

You can install wxPython on Mac just by downloading it from www.wxpython.org. Please take note of the following notice on their website:

NOTE: This installer is not signed by Apple, so by default your Mac will tell you it is corrupted and will not install it. You can get around this by temporarily relaxing the security settings in System Preferences. In the Security & Privacy section set "Allow applications downloaded from" to "Anywhere."

I have followed their directions and had no problem installing wxPython on Mac (Yosemite) once I changed those settings.