Closed ghost closed 8 years ago
It seems that you don't have ds9 in the path. Can you please do the following and report the results?
1) in a shell type: which ds9
:
ds9
proceed to point 22) start python or ipython (as you prefer) and run:
import os
os.environ['PATH']
check that the output contains the path to ds9.
3) if the answert to 2) is yes, then try again to create the DS9 object. If it fails try to run:
import subprocess
subprocess.call(['ds9'])
I added the location of DS9 to the path (/Users/rem/Applications) with no luck. Importing subprocess did not work either.
If you are on a Mac, the DS9 "file" in Applications is not actually the program executable, it's a directory containing a bunch of files ... including the executable ... which should be in the Contents/MacOS sub-directory. For example, on my Mac, the executable is at:
/Applications/SAOImage\ DS9.app/Contents/MacOS/ds9
In your case, the ds9 executable should be here:
/Users/rem/Applications/SAOImage\ DS9.app/Contents/MacOS/ds9
And in fact, you should be able to execute that ds9 file and have DS9 come up.
If that is the case, you have three options:
Aha. I understand now. I have added /Users/rem/Applications/SAOImage\ DS9.app/Contents/MacOS in my PATH. Now I get the following response:
d = pyds9.DS9() Error in startup script: couldn't read file "ds9/Frameworks/Saotk.framework/Resources/src/ds9.tcl": not a directory Traceback (most recent call last): File "
", line 1, in File "/Library/Python/2.7/site-packages/pyds9.py", line 403, in init raise ValueError('no active ds9 running for target: %s' % target) ValueError: no active ds9 running for target: ds9
Hmmm ... I see that happens on my Mac as well: I can't put the MacOS directory in my path and execute ds9 from the path, but I can execute it by supplying the full path. I'll have to ask Bill Joye, ds9 author, about that.
Anyway, at this point the easiest fix is to make a shell script called ds9 containing these lines:
#!/bin/bash
open -a "SAOImage DS9" --args $*
and put the shell script in your PATH, so that this gets executed by pyds9.
The alternative, which I suspect most people end up doing, is to download the X11 version of DS9 for the Mac (and also install XQuartz ...) and put this (Linux-like) executable in your PATH somewhere.
... and don't forget to chmod the script so that it has execute permission:
chmod +x ds9
@maelstromscientist : did you managed to solve your problem?
Sorry for the late reply. Unfortunately I have not managed to solve this problem yet.
I forgot to suggest the obvious: just start up DS9 before you start Python. When you call pyds9.DS9(), it should connect to the existing DS9 instance.
@montefra The problem here is that there are two flavors of DS9 on a Mac: the native Aqua version and X11-based command line version. The command-line version obviously works with pyds9 if the ds9 program is in the PATH. The Aqua version once worked also, because the SAOimage DS9.app folder contained a ds9 executable that could be run from the command line. Bill Joye now tells me that this can no longer be done (and we found that to be the case empirically). So users who have installed the Aqua version only cannot easily get DS9 started automatically.
On a Mac, we could consider code like this:
@ericmandel: It's possible to do it, it's just a little change.
Is /Applications
the only extra position or is there something else under the user directory?
Do we want to have it as a bugfix release with v1.8.1? If yes, we might have this out quite soon, and then I can port it to the devel branch later on.
Once it's done I'll need someone to test it on a mac.
The default location is /Applications, but I suppose you could check for the package in $HOME and $HOME/Applications as well. This is just a "best effort" attempt to find the package! The important thing is to issue a warning, which should say something like this:
For non-Mac (Linux):
Can't locate DS9 executable. Please add the DS9 directory to your PATH and try again.
For Mac:
Can't locate the X11 DS9 executable in your PATH or the Aqua SAOImage DS9 app in /Applications, $HOME or $HOME/Applications. Please configure your PATH or make SAOImage DS9 available in a known location.
It's a pretty simple addition, so a bug fix release is fine, if that is convenient for you. I'll test it on my Mac when you are ready.
Also, if you are not a Mac expert: when you look for the app, you'll be looking for a directory with a .app suffix, not an executable:
ls -ld /Applications/SAOImage\ DS9.app/
drwxr-xr-x@ 3 eric admin 102 Nov 17 15:03 /Applications/SAOImage DS9.app/
If that directory exists, you can execute open -a on it and the program will start:
open -a /Applications/SAOImage\ DS9.app/
I don't know how you deal with the space in the directory name, depends on which Python call you make.
I think that the best is to search for ds9 when when we define the ds9Globals["progs"]
entries, with the extra checks for mac.
Does it make sense to have pyds9 without a ds9 executable? If not, I'll convert the warning you suggest into exceptions, which abort the import of pyds9
Also, if you are not a Mac expert: when you look for the app, you'll be looking for a directory with a .app suffix, not an executable
Thank for the suggestion.
I don't know how you deal with the space in the directory name, depends on which Python call you make.
I think that is not a real issue. I'll figure it out.
Mostly: I hope to have the time to do it before Saturday (I'll go on vacation saturday and be back at the beginning of January).
Does it make sense to have pyds9 without a ds9 executable? If not, I'll convert the warning you suggest into exceptions, which abort the import of pyds9
I don't think you should abort the import. If a user has installed th Aqua version in an odd place they have the option of starting up DS9 manually before starting python. Therefore, the fact that pyds9 cannot find an executable does not meant that one is not already running!
Mostly: I hope to have the time to do it before Saturday (I'll go on vacation saturday and be back at the beginning of January).
And my vacation starts on Friday until January, so I would not worry about getting this done before we both disappear. Users currently have the option of starting up DS9 first, so there is a perfectly good method of using pyds9 on a Mac. We are just adding convnience.
@ericmandel : right; I should know it.
About the timing fine with me.
ps: If we don't interact anymore, have a Merry Christmas and a Happy New Year
@montefra I wish you the same! It's been a very good collaboration in 2015 and I look forward to even better things next year ...
It seems I have "solved" the problem using the above advice. I have removed all versions of DS9 except for the X11-based command line version, and added its location to my PATH. However, I must explicitly start DS9 before I can call ' d = pyds9.DS9() '. If I do not start ds9 before I execute the command then i get the child_exception error.
I'm hoping this bug gets fixed.
can you please run this command and if it fails past the whole output?
python -v "import pyds9; d = pyds9.DS9()"
ps: if the output is too long (and I guess it is), it probably better create a gist and link it here
Let's hope that #29 will solves the issue
v1.8.1 should soved this issue.
@maelstromscientist thank you for reporting it and for the patience.
I have recently installed both pyds9 and DS9 and can import pyds9 in python without any problems.
However when I call DS9 to open a DS9 window (d = pyds9.DS9()), it doesn't open a window, instead it gives me the following error:
Can this be fixed?