rca / PySPICE

Python wrapper around the NAIF CSPICE library
http://naif.jpl.nasa.gov/naif/
BSD 3-Clause "New" or "Revised" License
38 stars 15 forks source link

PySPICE fails to install #6

Open fergalm opened 11 years ago

fergalm commented 11 years ago

I'm having some trouble getting PySpice installed on my machine. It compiles without warning:

$ CSPICE_SRC=/home/fmullall/apps/cspice/ $ export CSPICE_SRC $ python setup.py build_ext running build_ext building '_spice' extension creating build creating build/temp.linux-x86_64-2.7 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/fmullall/apps/cspice/include -I/usr/include/python2.7 -c pyspice.c -o build/temp.linux-x86_64-2.7/pyspice.o gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/fmullall/apps/cspice/include -I/usr/include/python2.7 -c spicemodule.c -o build/temp.linux-x86_64-2.7/spicemodule.o creating build/lib.linux-x86_64-2.7 gcc -pthread -shared build/temp.linux-x86_64-2.7/pyspice.o build/temp.linux-x86_64-2.7/spicemodule.o -L/home/fmullall/apps/cspice/lib -L/usr/lib64 -lcspice -lpython2.7 -o build/lib.linux-x86_64-2.7/_spice.so

and installs without incident: $ python setup.py install --prefix=~/.local/ running install running build running build_py creating build/lib.linux-x86_64-2.7/spice copying spice/objects.py -> build/lib.linux-x86_64-2.7/spice copying spice/init.py -> build/lib.linux-x86_64-2.7/spice copying spice/misc.py -> build/lib.linux-x86_64-2.7/spice running build_ext running install_lib copying build/lib.linux-x86_64-2.7/_spice.so -> /home/fmullall/.local//lib64/python2.7/site-packages running install_egg_info Removing /home/fmullall/.local//lib64/python2.7/site-packages/Spice-1.0-py2.7.egg-info Writing /home/fmullall/.local//lib64/python2.7/site-packages/Spice-1.0-py2.7.egg-info

But when I run it, I get an error message: $ PYTHONPATH=$PYTHONPATH:/home/fmullall/.local/lib64/python2.7/site-packages/ $ python -c 'import spice' Traceback (most recent call last): File "", line 1, in File "spice/init.py", line 3, in from misc import File "spice/misc.py", line 3, in from _spice import ImportError: dynamic module does not define init function (init_spice)

The readme files suggests this might be a 32/64 bit problem, but cspice is compiling 64 bit as well, as best I can tell. Any ideas what I'm doing wrong?

michaelaye commented 11 years ago

what do you mean by "cspice is compiling 64 bit as well' ? Are you compiling your own cspice? I am asking because usually NAIF delivers usable binaries in its distribution files?

astromancer commented 10 years ago

Hi there!

I'm bumping into exactly the same problem described above. I'm running the 64bit Linux SPICE (http://naif.jpl.nasa.gov/naif/toolkit_C_PC_Linux_GCC_64bit.html) and python 2.7.

I also tried Apollo117's Python3 fork, but again got the same error.

Any advice?

fergalm commented 10 years ago

Hi Apodemus,

Firstly, apologies to Michael Aye, for some reason I never saw your email back when I was trying to get things installed. For what it's worth, I think I downloaded source code and complied it myself, but I can't be sure.

Anyway, I fixed the missing init function error, but this was a couple of years ago, and my memory is hazy about what I did exactly. I think the solution was to follow the manual instructions in README.rst

I think the line python mkwrapper.py /path/to/cspice > spicemodule.c

hardcoded a path to a shared object library previously generated by CSpice so that python knew where to look for it.

Hope that helps.

Fergal

On 6 August 2014 05:48, apodemus notifications@github.com wrote:

Hi there!

I'm bumping into exactly the same problem described above. I'm running the 64bit Linux SPICE ( http://naif.jpl.nasa.gov/naif/toolkit_C_PC_Linux_GCC_64bit.html) and python 2.7.

I also tried Apollo117's Python3 fork, but again got the same error.

Any advice?

— Reply to this email directly or view it on GitHub https://github.com/rca/PySPICE/issues/6#issuecomment-51329375.

astromancer commented 10 years ago

Hi Fergal

The manual build did the trick. So simple - should have done that straight away!

Thanks!

abieler commented 10 years ago

Have the same thing happening. Can not do the manual install as

python mkwrapper.py /myPathTo/PySPICE-master/cspice > spicemodule.c

fails with

File "mkwrapper.py", line 1077, in print main(cspice_toolkit) File "mkwrapper.py", line 1004, in main if gen_wrapper(curr_prototype, buffer): File "mkwrapper.py", line 259, in gen_wrapper param_info = parse_param(param) File "mkwrapper.py", line 837, in parse_param raise msg ValueError: invalid literal for int() with base 10: ''

I had pyspice working on several machines under linux, but with mint 17 it now fails. sidenote: when executing python setup.py build_ext it returns the same error as above, however rerunning the command will let it go through. also the install part works with no complaints.

cheers andre

drbitboy commented 10 years ago

Quick solution for N0065:

https://github.com/drbitboy/PySPICE

abieler commented 10 years ago

thanks, that worked fine. Although some funky permission issues:

/usr/local/lib/python2.7/dist-packages/spice/ and _spice.so had reading permissions disabled. so python could not import it although it was installed just fine.

matteobachetti commented 10 years ago

I have the same problem. The fix (manual installation with hardcoded full path) didn't work for me, on Ubuntu 14.04 LTS 64b and Mac OSX Mavericks (still 64b). Funky things happen with the parsing of include files in mkwrapper.py. In the file cspice/include/SpiceZpr.h, the line

                                SpiceDouble           termpts [ ][3] );

seems to give problems, producing in turn that

ValueError: invalid literal for int() with base 10: ''

message. That open bracket/space/closed bracket raises an exception in mkwrapper.py. Eliminating the space doesn't seem to take the problem away.

This does not happen in linux 32b AFAIK, as other colleagues installed it correctly, but I haven't had the time to install it on a VM and test it myself.

drbitboy commented 10 years ago

Quick solution for N0065:

https://github.com/drbitboy/PySPICE

drjmcauliffe commented 9 years ago

@drbitboy thanks for this fix.

tonyVeco commented 9 years ago

I have problems after installing PySPICE for linux suse 32 bit to use SPICE in the 32 bit version. The spice package correctly appears in the python library but I can not use any of the functions, python does not recognize them. What could be the problem?

michaelaye commented 9 years ago

Please specify "appears in the python library". Do you mean "import spice" worked? And what do you mean by "python does not recognize them". Just show the commands you are trying to do and their error messages.

On Mon, Mar 16, 2015 at 8:47 AM, antonio19812 notifications@github.com wrote:

I have problems after installing PySPICE for linux suse 32 bit to use SPICE in the 32 bit version. The spice package correctly appears in the python library but I can not use any of the functions, python does not recognize them. What could be the problem?

— Reply to this email directly or view it on GitHub https://github.com/rca/PySPICE/issues/6#issuecomment-81708551.

tonyVeco commented 9 years ago

snapshot1

This is the screenshot. I need to work with spice and I am trying to learn how to use it. First I would like to try some examples of the various functions. I need to use for example GETFOV and I was trying to reproduce an example from the documentation but when I try to call the function and load the kernel with FURNSH, python just see them as undefined variables. WHY?? how should i call the functions??? I usually works with python but this time i have problems

drjmcauliffe commented 9 years ago

This wrapper of SPICE is not really maintained. I'd checkout SpiceyPy by Andrew Annex if I were you: https://github.com/AndrewAnnex/SpiceyPy

drbitboy commented 9 years ago

Do this at a shell prompt:

python -c 'import spice;spice.tkvrsn("toolkit")'

please and paste the result in a response here.

drbitboy commented 9 years ago

whoops that should be:

python -c 'import spice;print(spice.tkvrsn("toolkit"))'
tonyVeco commented 9 years ago

This is what I got on the shell prompt:

antonio@linux-zrhc:~> python -c 'import spice;print(spice.tkvrsn("toolkit"))' Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/site-packages/spice/init.py", line 3, in from misc import File "/usr/lib/python2.7/site-packages/spice/misc.py", line 3, in from _spice import ImportError: dynamic module does not define init function (init_spice)

If you will help me it would be great...

drbitboy commented 9 years ago

I'll do my best

try this command:

nm -e path/to/_spice.so | grep init

and post the results again.

I don't know where your _spice.so file will be; for me it is in

build/lib.linux*/

under the top of the PySPICE/ area, but it is also in

~/.local/lib/python2.7/site-packages/_spice.so
tonyVeco commented 9 years ago

the result is : nm: 'path/to/_spice.so': No such file

drbitboy commented 9 years ago

you have to figure out what "path/to/" is.

tonyVeco commented 9 years ago

and how can I do it? i am getting confused !!!

drbitboy commented 9 years ago

there is a file called _spice.so, it has been installed on your system, the "path/to/" is the directory where it resides. You need to figure out what that directory is. e.g. try

nm -e /usr/lib/python2.7/site-packages/_spice.so | grep init

?

tonyVeco commented 9 years ago

It is exactly in the site-packages directory!! I found it before reading your post but I could not enter here!! What was wrong with the first installation? I did all that was in the instructions

drbitboy commented 9 years ago

I used "path/to/" as a placeholder for you to replace.

what was the result of the nm ... grep command?

tonyVeco commented 9 years ago

here is the result :

00002ee8 t __frame_dummy_init_array_entry 0000095c T _init

michaelaye commented 9 years ago

Actually, if you need the GETFOV function, you might indeed be better of with SpiceyPy, because our PySpice implementation does not yet encompass all available SPICE functions. @johnnycakes79 could confirm, if GETFOV works with SpiceyPy. I have a github version of PySpice that has GETFOV working as well, and maybe Brian's version works as well, but I don't remember if we ever merged it into here?

tonyVeco commented 9 years ago

Actually I have to use various function from Spice, not GETFOV but GETFOV can help me to understand some key elements of spice and the kernels..I did not know SpiceyPy, I have been told only about PySpice.

drbitboy commented 9 years ago

Your PySPICE did not build correctly, something is missing.

1) you need a symlink, named cspice, to the top of the NAIF cspice tree

2) python setup.py install

If you want to do a google hangout I can watch and coach you through it.

tonyVeco commented 9 years ago

This is what I did.. I downloaded the CSpice.tar.Z file for linux and I uncompressed it in the terminal with tar xfzv

then I put the Cspice uncompressed folder in the PySPICE-master folder that is obtained by uncompressing the PySpice-master.zip ..and then I followed the instructions of the readme file..

drbitboy commented 9 years ago

hmm, that should have worked.

try using my PySPICE (https://github.com/drbitboy/PySPICE), put in cspice, then

rm -R ./build python setup.py build python tests/test_btc.py

tonyVeco commented 9 years ago

I made what you suggest, and then the result of the test was : linux-zrhc:/home/antonio/Documents/PySPICE-master # python tests/test_btc.py Traceback (most recent call last): File "tests/test_btc.py", line 1, in import spice File "/usr/lib/python2.7/site-packages/spice/init.py", line 3, in from misc import File "/usr/lib/python2.7/site-packages/spice/misc.py", line 3, in from _spice import ImportError: dynamic module does not define init function (init_spice)

tonyVeco commented 9 years ago

It is maybe late, if you want to stop here for today I can understand it..really no problem

tonyVeco commented 9 years ago

i think the problem is PySpice and I would really like to know what it is, I have tried to install SpiceyPy and it works. Once I have installed it this is what I do : import SpiceyPy as sp

then just doing sp.(function_name) i obtain the list of all the functions..this should be the right thing, no?

drbitboy commented 9 years ago

There is something wrong with the build.

can you do a complete clean install?

and post all those commands and the output here.

Thanks!

drbitboy commented 9 years ago

Also, do this after the build:

tail -50 spicemodule.c

and paste the results here also.

Thanks!

tonyVeco commented 9 years ago

I have to thank you first!! Yes I can do a complete clean install , following your lines here!!

tonyVeco commented 9 years ago

sorry but i am not an expert of linux : cspice must be put in a different folder or in the uncompressed PySPICE folder, before executing the line

ln -s ~/cspice ./cspice

?

michaelaye commented 9 years ago

The idea is that the cspice folder goes into a safe place because you only change that very rarely. So you move the uncompressed cspice folder, for example, into your home folder with "mv cspice ~". Then you cd into the PySPICE folder, and in there you type : "ln -s ~/cspice" or "ln -s ~/cspice ./cspice" as Brian said, but that does the same, because by default this symbolic link goes where you currently are. This symbolic (or 'soft') link makes it look like to the PySPICE compilation that the cspice folder is just there inside the PySPICE folder, while it actually is in your home folder.

On Mon, Mar 16, 2015 at 7:56 PM, antonio19812 notifications@github.com wrote:

sorry but i am not an expert of linux : cspice must be put in a different folder or in the uncompressed PySPICE folder, before executing the line

ln -s ~/cspice ./cspice

?

— Reply to this email directly or view it on GitHub https://github.com/rca/PySPICE/issues/6#issuecomment-82030046.

tonyVeco commented 9 years ago

oh thanks!!!I have always worked with windows and suddenly I have to change and move to linux, it is just few days since I have begun with it..thanks i am going to do it...

tonyVeco commented 9 years ago

problem, I obtain this one :

ntonio@linux-zrhc:~/Pictures/PySPICE-master> cd antonio@linux-zrhc:~> mv cspice ~ mv: ‘cspice’ and ‘/home/antonio/cspice’ are the same file antonio@linux-zrhc:~> cd Pictures antonio@linux-zrhc:~/Pictures> cd PySPICE-master antonio@linux-zrhc:~/Pictures/PySPICE-master> ln-s~/cspice ./cspice bash: ln-s~/cspice: No such file or directory antonio@linux-zrhc:~/Pictures/PySPICE-master>

and cspice is in the directory that contain Pictures

drbitboy commented 9 years ago

there are two spaces in there

ln   -s    ~/cspice

-b

tonyVeco commented 9 years ago

other problem : linux-zrhc:/home/antonio/Pictures/PySPICE-master # python setup.py build Unable to find CSPICE source at cspice. Please untar the source there or set the environment variable CSPICE_SRC

tonyVeco commented 9 years ago

it is endless...

drbitboy commented 9 years ago

other problem : linux-zrhc:/home/antonio/Pictures/PySPICE-master # python setup.py build Unable to find CSPICE source at cspice. Please untar the source there or set the environment variable CSPICE_SRC

No, not endless, we just need patience; you are very close to solving this.

That problem was caused by mis-typing the "ln -s ~/cspice" command, that is, typing it without the spaces between the ln, -s, and ~/cspice.

Go back and enter the

command, with the spaces this time, then do the

command again.

drjmcauliffe commented 9 years ago

@michaelaye the getfov test in SpiceyPy works. I've not used it myself... yet!

tonyVeco commented 9 years ago

Thank you so much for the hint, I have installed SpiceyPy in the meantime and at the moment it seems to work fine. By the way @johnnycakes79 I am an ESAC trainee and I saw here some minutes ago that you are not so far..I hope I can talk with you just to thank you directly . However I am still curious to understand why PySpice does not work on my laptop..

drbitboy commented 9 years ago

an alternative to the ln command is to do this:

If your shell is csh or tcsh (use the ps command to find out):

setenv CSPICE_SRC ~/cspice

or, if your shell is bash (again, use ps):

export CSPICE_SRC=~/cspice

those commands will tell the PySPICE setup.py where to find the cspice includes and libraries; the effect of those commands is persistent until you exit the shell or terminal window.

tonyVeco commented 9 years ago

Here it was night @drbitboy and I stopped trying but I am going on now again. Yes we need a lot of patience, you have a lot!!! thanks for helping me..

drbitboy commented 9 years ago

hmm, I just looked at SpiceyPy again, it has a lot more coverage (of the SPICE library) than the last time I checked.

drjmcauliffe commented 9 years ago

@antonio19812 I'm in the M-Building (M004). @drbitboy I'm pretty "convinced" of SpiceyPy up until now... and the author @andrewannex appreciates help with the testing and documentation. I'm also planning to prepare a suite of IPython Notebooks with SPICE tutorials (publicly available of curse) if anyone wants to help out.