spacetelescope / imexam

imexam is a python tool for simple image examination, and plotting, with similar functionality to IRAF's imexamine
http://imexam.readthedocs.io
BSD 3-Clause "New" or "Revised" License
74 stars 45 forks source link

Imexam modules bug #179

Closed MADECICCO closed 5 years ago

MADECICCO commented 5 years ago

Hi everyone!

I installed imexam using pip install method: " sudo - H pip3 install imexam", it was ok.

But certain classe/fucntion did not load as :

-list_active_ds9() -ds9('...') -display_help()

error: " module 'imexam' has no attribute..... "

AND worst: when calling -> "window=imexam.connect('ds9')'" ( or many others analogs steps, as explained in the imexam webpage docs, no single one worked out), the following error happened ..:

**"

NotImplementedError Traceback (most recent call last)

in 1 ----> 2 window=imexam.connect('ds9') /usr/local/lib/python3.6/dist-packages/imexam-0.8.2.dev375-py3.6-linux-x86_64.egg/imexam/connect.py in __init__(self, target, path, viewer, wait_time, quit_window, port) 84 warnings.warn("**Unsupported viewer, check your installed " 85 "packages**\n") ---> 86 raise NotImplementedError 87 88 # init sets empty data array until we can load or check viewer NotImplementedError:** " I tried GINGA, but the same issue/error Well, after many tries, I decide to uninstall it, and using the installation instructions I decide to try : "git clone --recursive...etc ", and then "sudo -H python3 setup.py install" . All good, no error. But after importing imexam module (unitl this point all fine) the same before bugs appeared ! - I tryed, also change to "inet", "local" , and as well I tried all examples explained on the issues, waiting time, XAP_method,... nothing works :( Is it supposed to work inside an env astroconda ? I am using: Ubuntu 18.4, Jupyter notebook, and pyhon 3.6, ds9 last version, ginga last version
MADECICCO commented 5 years ago

EDIT1 :

After reinstalling GINGA, using conda install , imexam.connect recognized it, finally

But DS9 keeps same issue: " ...n("Unsupported viewer, check your installed " 85 "packages\n")..."

MADECICCO commented 5 years ago

EDIT 2:

inside ../imexam/connect.py there are the following lines:

" try: import xpa have_xpa = True from .ds9_viewer import ds9 except ImportError: have_xpa = False

"

So I tested import xpa and an error of no 'module xpa' occurred, so I believe the variable "have_xpa" is set to False, and the package is not capable to recognize 'ds9' viewer, as the variable :'_possible_viewers" is empty.

sosey commented 5 years ago

Hi there.. lets try a quick check. You have ds9 installed, available either in your common path, or as part of the virtual environment that you are using. You should be able to get the path to the executable, try launching DS9 and see if it comes up. If it's on your path, which ds9 should return the correct location.

If that works, you can give connect the path to your ds9 executable when you instantiate: viewer=imexam.connect(path='the-path-to-ds9')

Let me know if either of those things succeed or fail and we can debug from there :-)

MADECICCO commented 5 years ago

Hi , the path to ds9 is : '/usr/local/bin/ds9'

it takes long time to load, but it works.

I tried also loading inside jupyter notebbok and it is loaded all right, no problem.

But the bug keeps happening:

viewer=imexam.connect(path='/usr/local/bin/')

'

usr/local/lib/python3.6/dist-packages/imexam-0.8.2.dev375-py3.6-linux-x86_64.egg/imexam/connect.py:84: UserWarning: Unsupported viewer, check your installed packages

warnings.warn("**Unsupported viewer, check your installed "


NotImplementedError Traceback (most recent call last)

in ----> 1 viewer=imexam.connect(path='/usr/local/bin/ds9', wait_time=120) /usr/local/lib/python3.6/dist-packages/imexam-0.8.2.dev375-py3.6-linux-x86_64.egg/imexam/connect.py in __init__(self, target, path, viewer, wait_time, quit_window, port) 84 warnings.warn("**Unsupported viewer, check your installed " 85 "packages**\n") ---> 86 raise NotImplementedError 87 88 # init sets empty data array until we can load or check viewer NotImplementedError: ' I mean I can load DS9 w/terminal or inside jupyter notebook, but imexam do not recognize neither two ways .
MADECICCO commented 5 years ago

EDIT 3:

BTW, even functions/classes described above don't load.

-list_active_ds9() -ds9('...') -display_help()

error: " module 'imexam' has no attribute..... "

sosey commented 5 years ago

Hi there - I'm having problems recreating your issue. I've included a screen shot of some of the functions you mention, there are 3 different ds9 windows in it that were opened in different ways, they have different names and different things displayed in them according to the commands on the terminal that's also in the image.

It looks like you might be running on linux? Will you send me your os spec, uname -a? Also, from a python terminal try and import the xpa and let me know what it says: import xpa. if it imports tell me the path to it with xpa.__file__

we'll figure this out!

Screen Shot 2019-07-03 at 1 55 57 PM
MADECICCO commented 5 years ago

uname -a:

Linux 4.15.0-52-generic #56-Ubuntu SMP Tue Jun 4 22:49:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

import xpa
Out[3]: '/home/decicco/.local/lib/python3.6/site-packages/xpa.py'

MADECICCO commented 5 years ago

Edit:

imexam.path :

['/usr/local/lib/python3.6/dist-packages/imexam-0.8.2.dev375-py3.6-linux-x86_64.egg/imexam'

imexam.version:

0.8.2dev375'

Seems your version is former...

sosey commented 5 years ago

The difference in our versions shouldn't be an issue, for completeness I pulled the version you installed for testing. I'm unable to replicate your issue, as long as the location to ds9 is on my path, or I give imexam the startup location for the executable, then it's able to start ds9 and make the connection. I've tried this inside several environments, and using the pip installed release and the master branch. One usage question, are you running this from a single notebook cell that tries to execute all the calls at once? If so, import imexam and start the connection in one cell, that will give the process time to establish, then start using the control object (what you assigned to connect() in the next cell.

You're paths make me think that you are not running in a virtual environment, it should be working inside a conda environment and it also shouldn't care if your install of ds9 is internal or external to the environment, as long as it's on your PATH or you give it the path to the executable. I also see your import of xpa is coming from a source other than I expected. Do you also have pyds9 installed? That package installs it's own xpa.py directly into site-packages. imexam uses a cython wrapped extension that installs into site-packages/xpa.py along with a .so file. When youimport xpaand thenxpa.fileit should be referencing the shared object file. It's possible that installation of the two packages are conflicting on your system. The latest version ofpyds9` should be installing the xpa file into its local area and looking for a system installed xpa.

If you have pyds9 installed, try uninstalling, then try imexam again. I should probably move the imexam .so file to it's own directory as well, I thought I already had, but let me know if the above works for you. If you don't have pyds9 also installed, I'll have to think a little more what could be going on with your system. You might also check what version of ds9 you are running as at least v8.0.1 for the Quartz installed app had a bug with the xpa socket specification that imexam uses. The lasted release of that fixes the issue, I didn't see it show up on any of the linux/Xwin versions I tried locally.

MADECICCO commented 5 years ago

Hi !

In fact, I did not create a 'conda env'.

So, for just testing, I uninstalled pyds9, and now no more DS9 bug. The error now is: "RuntimeError: The ds9 process is externally killed."

But I did not reinstall yet a new pyds9.

So my next step will be create an "imexam env", and try again.

Also, apparently the modules bug are fixed:

imexam.list_active_ds9()

_DS9 imexam1562767514.592104 gs 7f000101:39229 decicco

{'7f000101:39229': ('imexam1562767514.592104', 'decicco', 'DS9', 'gs')}_

:)

sosey commented 5 years ago

excellent, I'm glad we're making progress...let me know how it continues to go :)

Note though, it should work whether or not you decide to use a conda or other virtual environment to install your software...the virtual environments just help keep packages and their dependencies separate and easier to manage.

MADECICCO commented 5 years ago

HI!! Uninstalled imexam, installed again, and voi la...:) Screenshot from 2019-07-10 11-36-34

MADECICCO commented 5 years ago

Now, I ll redo all steps for a conda env "name"

P.S.: I did not reinstall pyds9, is it really necessary?

sosey commented 5 years ago

If you're not using pyds9 then it's not necessary to install. If you do decide to install, make sure its the most recent version that doesn't stick the xpa.py file directly in the site-packages/ directory.

just for completeness on my end, when you startup a python session, and import xpa what does xpa.__file__ return for you now?

MADECICCO commented 5 years ago

I did not : 'import xpa...

MADECICCO commented 5 years ago

I can reload my jup notebook session again importing xpa, if you want

sosey commented 5 years ago

right, but give it a go separately, in a terminal with a python session for example, and let me know what file path is returned?

MADECICCO commented 5 years ago

Done!! decicco@patolino:~$ ipython Python 3.6.7 (default, Oct 22 2018, 11:32:17) Type 'copyright', 'credits' or 'license' for more information IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import xpa

In [2]: xpa.file
Out[2]: '/usr/local/lib/python3.6/dist-packages/xpa.cpython-36m-x86_64-linux-gnu.so'

In [3]:

sosey commented 5 years ago

interesting. thanks.

shall we close this help call for now? If you have any more problems as you start playing with the package definitely report back and we'll figure them out. :)

cheers