Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Problem running pyds9 #95

Open
dalilas98 opened this issue Apr 8, 2020 · 40 comments
Open

Problem running pyds9 #95

dalilas98 opened this issue Apr 8, 2020 · 40 comments

Comments

@dalilas98
Copy link

When I run the code given on GitHub to use ds9, I receive this error "raise ValueError('no active ds9 running for target: %s' % target)" It was working perfectly before and I'm unsure what the problem is

@DougBurke
Copy link
Collaborator

Could you include the actual code you used, what python version, and the version of pyds9 used (or how you installed it)?

@dalilas98
Copy link
Author

import pyds9
print (pyds9.ds9_targets())
d = pyds9.DS9()

I'm using python 3.7 and the most updated version of pyds9.

@DougBurke
Copy link
Collaborator

DougBurke commented Apr 10, 2020 via email

@dalilas98
Copy link
Author

No you're fine. I'm using MacOS and yes the master branch.

@DougBurke
Copy link
Collaborator

Unfortunately I don't have a macOS machine to debug.

Do you have an idea of what version was working (or even if you're able to run some bisection with the master branch, either manually or with git)?

@ericmandel
Copy link
Owner

@dalilas98 This works for me on my Mac with a freshly installed copy of pyds9. I'm guessing that, in your case, the DS9 program is being started up by the pyds9.DS9() call, but the default 10 second wait time is too short (possibly because it takes a long time to start up the X server?). You can test this theory by extending the wait time:

d = pyds9.DS9(wait=60)

and see if that fixes things.

It's also possible that there is a mixup between the XPA_METHOD used by DS9 and the XPA_METHOD used by Python/pyds9. Did you set the XPA_METHOD environment variable at any point? Do you already have an xpans program running before starting Python?

@ericmandel
Copy link
Owner

@dalilas98 btw, if you are getting an error after a long delay (e.g. 30 to 120 secs), the probable cause is your Mac firewall not allowing connections to xpans. That is, some time in the past, you might have denied xans access to incoming conections. You can check/fix this in the System Preferences -> Security and Privacy -> Firewall -> Firewall Options tab.

@kenearnold16
Copy link

Hi @ericmandel I tried setting the wait time to 60 and I also have the firewall disabled in my system preferences but I still get the error. If I understand it correctly could there be a problem with the inet sockets that ds9 and xpa are using to communicate with each other?

@ericmandel
Copy link
Owner

Yes, this seems to be an inet socket problem. You can try a different XPA socket communication method:

export XPA_METHOD=local               # use local (file) unix sockets

or:

export XPA_METHOD=localhost        # use the localhost (127.0.0.1) instead of hostname socket

Note that this environment variable should be set before starting Python.

@kenearnold16
Copy link

I just want to make sure that I am doing this correctly, do I type these commands into the terminal(base) on my mac? If so this seems not to be working either.

@ericmandel
Copy link
Owner

Yes, you do this (assuming you are using the bash and ds9 is not running yet):

export XPA_METHOD=local
python3
>>> import pyds9
>>> d = pyds9.DS9()

@ericmandel
Copy link
Owner

Once you have set XPA_METHOD, as a check, you can start up ds9 manually and then look at File->XPA->Information and for local sockets, you should see a filename:

Screen Shot 2020-04-12 at 12 52 15 PM

@ericmandel
Copy link
Owner

ericmandel commented Apr 12, 2020

Which version of ds9 are you running? I am running the X11 version of v8.1.

Is DS9 starting up??

@kenearnold16
Copy link

When I type the commands into the terminal ds9 does start up but when I check the XPA information it displays 7f000001:54215. I am running v8.1 but I am unsure if it is the X11 how can I check if it is X11?

@kenearnold16
Copy link

I am mostly trying to get the module to work on spider from anaconda which is where I get the error message.

@ericmandel
Copy link
Owner

If you set XPA_METHOD to local in the shell that eventually starts up ds9, but are seeing 7f000001:54215 as ds9's XPA method, then something is wrong: that is still the inet method being used. I would look for a ds9 script in your PATH (which is what pyds9 is finding and using to start up ds9). If you find a script, post it here. I hope it doesn't blithely set XPA_METHOD to inet!

@ericmandel
Copy link
Owner

ericmandel commented Apr 12, 2020

I am unsure if it is the X11 how can I check if it is X11?

The X version looks like this:

Screen Shot 2020-04-12 at 1 45 55 PM

When its running, you'll also see the X11 server running, with the usual X11 dock icon:

Screen Shot 2020-04-12 at 1 48 09 PM

The Aqua version looks more like a Mac app, I don't have it installed, but its much different.

@ericmandel
Copy link
Owner

OK, I've installed the Aqua version of DS9, and it also works with pyds9 on my machine. Aqua DS9 looks like this:

Screen Shot 2020-04-12 at 2 29 42 PM

I've run it both using inet and local sockets. I'm pretty sure this is an inet socket problem with the complication of not successfully switching to local sockets.

@kenearnold16
Copy link

Screen Shot 2020-04-12 at 2 55 39 PM

This is the out I get when I export XPA_METHOD and check the path

@ericmandel
Copy link
Owner

To find ds9 in your PATH, you have to do something like:

which ds9

For example, I get:

which ds9
/Users/eric/bin/ds9

You can find out what type of file this is using (to continue the example):

file /Users/eric/bin/ds9
/Users/eric/bin/ds9: Mach-O 64-bit executable x86_64

which means I have the ds9 executable in my path, not a script. If you have a script it will say something like:

POSIX shell script text executable, ASCII text

and in that case, you should just show its contents.

@kenearnold16
Copy link

So I successfully got the XPA_METHOD to change in DS9 now when I open the information it says XPA_METHOD: /var/folders/8b/64_1pvzn11z6y1s35jnvn53c0000gp/T//DS9_ds9.39095 but when I try to find ds9's path the terminal says that ds9 is not found.
Screen Shot 2020-04-12 at 3 28 03 PM

@kenearnold16
Copy link

From the terminal pyds9 executes successfully but it still stalls from spyder.

@ericmandel
Copy link
Owner

From the terminal pyds9 executes successfully but it still stalls from spyder.

Sorry, I know nothing about spyder or anaconda or Python for that matter. @DougBurke is trying to help with Python-specific issues (as opposed to the xpa/network/etc issues we have talking about today) and he might be able to make a suggestion ...

@ericmandel
Copy link
Owner

For example, I have no idea anaconda is finding ds9 if it doesn't appear in your PATH ...

@dalilas98
Copy link
Author

I successfully ran the export XPA_METHOD=local command but I'm sill receiving the same error.

File "/opt/anaconda3/lib/python3.7/site-packages/pyds9.py", line 449, in init
raise ValueError('no active ds9 running for target: %s' % target)
ValueError: no active ds9 running for target: ds9

Also I don't have a path when I type which ds9.

@ericmandel
Copy link
Owner

My confusion: is DS9 starting up successfully but you are erroneously getting this message, or is DS9 not starting successfully and the error message is correct but unwanted?

@dalilas98
Copy link
Author

My apologies for the confusion. The command that gives me an error is " d = pyds9.DS9()" I tried the solution above but none of them are correcting my error.

@ericmandel
Copy link
Owner

No I understand that ... what I don't understand is the status of DS9 when you execute pyds9.DS9(). The possibilities are:

  1. ds9 is already running then you execute pyds9.DS9() and you erroneously get the message
  2. ds9 is not yet running and is started up by pyds9.DS9() (as it should be by default, unless you pass the start=False flag) and you erroneously get the message
  3. ds9 is not yet running and is not started up by pyds9.DS9() as it should be, and you get a correct message
  4. some other?

Which situation are we dealing with?

@dalilas98
Copy link
Author

Ds9 is not yet running and is started up by the command and I get the error message.

@ericmandel
Copy link
Owner

OK, so the thing to check is whether both pyds9 and DS9 are using the same XPA transport mechanism. To do this, run pyds9.DS9() and in Python, check the _method property. On my Mac, I have XPA_METHOD set to local, so I see this:

>>> d = pyds9.DS9()
>>> d._method
'local'

Then check DS9 File -> XPA -> Information. I see a local file like this:

XPA_VERSION:	2.1.18
XPA_CLASS:	DS9
XPA_NAME:	ds9
XPA_METHOD:	/var/folders/hl/0rxttnz48xldqq006s7f7t980000gp/T//DS9_ds9.43145

If I am using inet sockets, I will see this:

>>> d = pyds9.DS9()
>>> d._method
'inet'

and

XPA_VERSION:	2.1.18
XPA_CLASS:	DS9
XPA_NAME:	ds9
XPA_METHOD:	7f000001:56341

What do you see?

@kenearnold16
Copy link

@ericmandel I was able to communicate successfully with spyder but I had to create a SampHub with astropy

Screen Shot 2020-04-13 at 10 14 55 PM

After I set this up I am able to communicate with ds9 using pyds9 with no problem

@ericmandel
Copy link
Owner

@kenearnold16 How weird! Of course, pyds9 has nothing to do with samp, but whether either DS9 or spyder is in some strange configuration requiring samp I cannot say. Perhaps @wjoye might have some insight into the DS9 side, or @DougBurke into spyder. Really strange ...

@wjoye
Copy link
Collaborator

wjoye commented Apr 14, 2020 via email

@DougBurke
Copy link
Collaborator

I have no experience with spyder. I also wonder if the issue for @kenearnold16 was different to the original reporter, @dalilas98 [I haven't been following this closely enough]

@ericmandel
Copy link
Owner

OK, @kenearnold16, this looks like a spyder problem (since pyds9 knows nothing about samp, and DS9 does, but does not support a samp hub), so someone with expertise re: spyder will have to look into this. Perhaps you know someone who can help? Or perhaps you found yourself a satisfactory work-around?

@kenearnold16
Copy link

To me it appears that the problem with spyder is that I can't send or receive data at all with pyds9, however if I try from the base terminal there's no issues sending and receiving data. In spyder if I create the hub I can successfully send and receive data and then afterwords I can use d.set() or d.get() to manipulate and adjust data in ds9 how I like. The code I have in spyder seems to be working so far I think I've got it from here. Thank you!

@dalilas98
Copy link
Author

I fixed my previous error, but now when I try to import pyds9 it says

Traceback (most recent call last):
File "", line 1, in
File "/Users/dscott09/Desktop/pyds9-master/pyds9/init.py", line 20, in
from .pyds9 import *
File "/Users/dscott09/Desktop/pyds9-master/pyds9/pyds9.py", line 31, in
from . import xpa
File "/Users/dscott09/Desktop/pyds9-master/pyds9/xpa.py", line 33, in
raise ImportError("can't find XPA shared library")
ImportError: can't find XPA shared library

@ericmandel
Copy link
Owner

The XPA library is compiled during install, so might this indicate that the compile was not done?
Here us what I see when installing pyds9:

eric% pip3 install git+https://github.com/ericmandel/pyds9.git#egg=pyds9
Collecting pyds9
  Cloning https://github.com/ericmandel/pyds9.git to /private/var/folders/hl/0rxttnz48xldqq006s7f7t980000gp/T/pip-install-41_lhako/pyds9
  Running command git clone -q https://github.com/ericmandel/pyds9.git /private/var/folders/hl/0rxttnz48xldqq006s7f7t980000gp/T/pip-install-41_lhako/pyds9
  Running command git submodule update --init --recursive -q
Requirement already satisfied: astropy in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyds9) (3.1.2)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyds9) (1.16.4)
Installing collected packages: pyds9
    Running setup.py install for pyds9 ... done
Successfully installed pyds9-1.9.dev0

with a noticable delay at the setup.py line while xpa is being compiled. You could try uninstall and then re-install to see what happens on your machine.

@dalilas98
Copy link
Author

That worked for the XPA error, thank you. However, it now is back to this error

d = pyds9.DS9()
Traceback (most recent call last):
File "", line 1, in
File "/Users/dscott09/opt/anaconda3/lib/python3.7/site-packages/pyds9.py", line 449, in init
raise ValueError('no active ds9 running for target: %s' % target)
ValueError: no active ds9 running for target: ds9
d.set("file /Users/dscott09/Downloads/casa_0.5-1.5keV.fits")
Traceback (most recent call last):
File "", line 1, in
NameError: name 'd' is not defined

@ericmandel
Copy link
Owner

@dalilas98 If you are still in this state of affairs (see above):

Ds9 is not yet running and is started up by the command and I get the error message.

please work through the suggestions above that start:

OK, so the thing to check is whether both pyds9 and DS9 are using the same XPA transport

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants