spectralpython / spectral

Python module for hyperspectral image processing
MIT License
573 stars 139 forks source link

view_cube import error #45

Closed 861 closed 8 years ago

861 commented 8 years ago

I have installed wxPython on my win10 x64 correctly ,but when I use spectral.view_cube(img, bands=[0, 1, 2])

Traceback (most recent call last): File "N:\new.py", line 7, in spectral.view_cube(img, bands=[0, 1, 2]) File "C:\WinPython-32bit-2.7.10.2\python-2.7.10\lib\site-packages\spectral\graphics\graphics.py", line 178, in view_cube from spectral.graphics.hypercube import HypercubeWindow File "C:\WinPython-32bit-2.7.10.2\python-2.7.10\lib\site-packages\spectral\graphics\hypercube.py", line 73, in raise ImportError("Required dependency wx.glcanvas not present") ImportError: Required dependency wx.glcanvas not present

tboggs commented 8 years ago

As the exception indicates, it was not possible to import the glcanvas submodule from the wx package. Is it possible that you don't have PyOpenGL installed? Take a look here for more info.

861 commented 8 years ago

I have also installed pyopengl on my pc

tboggs commented 8 years ago

Please try running the example app at the link in my previous message and let me know the result.

tboggs commented 8 years ago

Actually, you may want to try this example for more informative output:

http://wiki.wxpython.org/GLCanvas%20update

861 commented 8 years ago

I can run the demo correctly as follow: image image image

tboggs commented 8 years ago

Interesting. Please try the following:

Open a new python session and type:

>>> from wx import glcanvas

Then, exit python, open a new python session, and type:

>>> import wx
>>> from wx import glcanvas

Do both of those tests work for you without errors?

861 commented 8 years ago

image image

tboggs commented 8 years ago

Ok. A few more things to clarify..

When you call view_cube, are you using ipython or the standard python interpreter?

When you call view_cube, are you doing it from an interactive ipython session?

Lastly, I notice you are using a script called "new.py". That is potentially dangerous because there is a standard python module named "new" and you could be masking it (see here). Please try renaming that file and see if the error goes away.

861 commented 8 years ago

Thanks for your help!I just try it again!I can use the ipython run it correctly!But there is something wrong with the standard python interpreter!

tboggs commented 8 years ago

For the interactive graphical functions of SPy to work, the ipython interpreter is required. But I'm still surprised by the import exception you received. Did changing the file name eliminate that error?

861 commented 8 years ago

I have changed my file name ,But the exception is still exist

861 commented 8 years ago

I also have another problem about the test!


Running memmap tests.

Testing memmaps with BIL image file. Saving C:\Users\Hmily\spectral\spectral_test_files\memmap_test_bil.img Testing bil_memmap_read..................................... Traceback (most recent call last): File "C:\WinPython-32bit-2.7.10.2\python-2.7.10\lib\runpy.py", line 162, in _run_module_as_main "main", fname, loader, pkg_name) File "C:\WinPython-32bit-2.7.10.2\python-2.7.10\lib\runpy.py", line 72, in _run_code exec code in run_globals File "C:\Users\Hmily\spectral\spectral\tests\run.py", line 68, in test.run() File "spectral\tests\memmap.py", line 192, in run suite.run() File "spectral\tests\memmap.py", line 186, in run test.run() File "spectral\tests\spytest.py", line 76, in run method() File "spectral\tests\memmap.py", line 108, in test_bil_memmap_read self.create_test_image_file() File "spectral\tests\memmap.py", line 95, in create_test_image_file force=True) File "spectral\io\envi.py", line 455, in save_image _write_image(hdr_file, data, metadata, **kwargs) File "spectral\io\envi.py", line 687, in _write_image fout = builtins.open(img_file, 'wb', bufsize) IOError: [Errno 22] invalid mode ('wb') or filename: u'C:\Users\Hmily\spectral\spectral_test_files\memmap_test_bil.img'

861 commented 8 years ago

image

tboggs commented 8 years ago

I can't explain your unit test error or why it would be related to the SPy module. The error is associated with a basic file-open operation. To figure out what is going on, you could create the directory (C:\Users\Hmily\spectral\spectral_test_files) manually and try running the same command from the python command line to see if that works:

>>> open(u'C:\\Users\\Hmily\\spectral\\spectral_test_files\\memmap_test_bil.img', 'wb', 100)

If that works, I would retry running the SPy unit tests from a different directory (not from within the spectral directory) and see if it works from there. If you still get the error, please report what versions of windows and python you are using.

861 commented 8 years ago

I have tried the command:open(u'C:\\Users\\Hmily\\spectral\\spectral_test_files\\memmap_test_bil.img', 'wb', 100) It worked!But when I retry unit tests in a different directory ,the error is still exist on win10 x64 ,python 2.7.10.I will try it on Ubuntu tomorrow.Thank you very much!

tboggs commented 8 years ago

I'm closing this issue since the original problem was due to not running ipython. If the unit test error can be reproduced on another system (Windows or other), we'll create a separate issue.