How to install wxversion for Python

会有一股神秘感。 提交于 2019-12-02 17:52:54

问题


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.



来源:https://stackoverflow.com/questions/31466411/how-to-install-wxversion-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!