SpiceyPy Installing

Hi
I am trying to install SpiceyPy on a Pi4 running Ubuntu
i get a compilation error

Error: compilation of shared spice.so build exit status: (‘256’,)

is it a limitation of the PI or is it that i missing some other software to compile it

thank you for any help

Using cached spiceypy-3.1.1.tar.gz (262 kB)
Requirement already satisfied: numpy>=1.17.0 in /usr/local/lib/python3.8/dist-packages (from spiceypy) (1.19.4)
Building wheels for collected packages: spiceypy
Building wheel for spiceypy (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-of4xyfud/spiceypy_efafb97d7eb046a598d5cc7afa5f98b9/setup.py’"’"’; file=’"’"’/tmp/pip-install-of4xyfud/spiceypy_efafb97d7eb046a598d5cc7afa5f98b9/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-25si54up
cwd: /tmp/pip-install-of4xyfud/spiceypy_efafb97d7eb046a598d5cc7afa5f98b9/
Complete output (17 lines):
running bdist_wheel
running build
running build_py
Checking the path /tmp/pip-install-of4xyfud/spiceypy_efafb97d7eb046a598d5cc7afa5f98b9/cspice
Unable to find CSPICE at /tmp/pip-install-of4xyfud/spiceypy_efafb97d7eb046a598d5cc7afa5f98b9/cspice. Attempting to Download CSPICE For you:
Gathering information…
SYSTEM: Linux
PROCESSOR: aarch64
MACHINE: 64bit
Downloading CSPICE for PC_Linux_GCC_64bit…
Unpacking… (this may take some time!)
Host OS: Linux
/usr/bin/ld: F77_aloc.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: F77_aloc.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: F77_aloc.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
Error: compilation of shared spice.so build exit status: (‘256’,)

Hi, I would suggest you report your issue to https://github.com/AndrewAnnex/SpiceyPy/issues @AndrewAnnex. Good luck! :slight_smile:

I would also recommend posting to GitHub. You might be forging a new path doing this. But it looks like NAIF will be testing on a Raspberry PI but probably still nothing to report as of yet (see page 2): https://naif.jpl.nasa.gov/naif/SPICE_News_Apr_2020.pdf

CSPICE on ARM is not currently supported by the Naif but I have heard that it is possible to compile CSPICE for ARM from the folks supporting the ruby spice wrapper. Currently spiceypy does not attempt the steps necessary to recompile spice when installed through pypi for Linux/macOS. I also don’t own a raspberry pi to attempt to figure out any additional steps that could be needed, but maybe the Ruby Spice authors would be willing to provide the necessary instructions. If you are able to compile CSPICE yourself then you can provide the shared library at install time using an environment variable (see spiceypy docs).

Thank you all
ruby spice seems the option

l will give it a go

thanks again

Hello vigilancewx,
I have spiceypy running on a Pi3. I managed to convert the libs from the ruby package into something workable. If you’re interested I’ll try to recap what steps were nescessary to do this.

Edit, I found the appropriate commands in the shell history, hope this works for you!

  1. sudo pip3 install setuptools wheel
  2. sudo pip3 install numpy
  3. sudo pip3 install spiceypy
    *fails, iirc
  4. download naif-spice-2.25.gem from https://lunaserv.lroc.asu.edu/downloads.html
  5. unpack with: tar xvf naif-spice-2.25.gem
  6. cd lib/arm-linux-gnueabihf/
  7. unpack libspice.a with: ar -x libcspice.a
  8. repack to spice.so: gcc -shared *.o -o spice.so
  9. copy spice.so to the path where spiceypy expects it (path might be different for you)
    sudo cp spice.so /usr/local/lib/python3.7/dist-packages/spiceypy/utils/
  10. this install was also needed on my Pi3: sudo apt-get install libatlas-base-dev

Fingers crossed! :wink:

1 Like

thank you PhaseIv i will give it a go

Hi PhaseIV
i am with you on your steps 1-10
but what is the repack command step 8 could you elaborate i am unsure what you typed into your Pi
thanks

Steps 7 and 8 are for converting the static spice library (lib.a) into a shared library (lib.so).
When you unpack the lib (step 7, “ar -x libcspice.a”) you’ll see a lot of object files (*.o) appear in the directory. This is good because now you don’t have to compile the spice code from scratch yourself.
Just pack these object files into a new shared library (step 8, “gcc -shared *.o -o spice.so”)
and copy the new file spice.so to the spiceypy/utils directory (step 9). Together with step 10 this method worked for me. I hope it will work for you too!

Hello phaseIV

1-7 no problems

I am unable to repack the files
gcc -shared *.o -o spice.so

it returns the error
/usr/bin/ld: abort_.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

gcc is version 10.2.0

I have a pi4 so I tried the 64 bit
pi@pi-desktop:~/naif-spice/ext/lib/x86_64-linux$ gcc -shared *.o -o spice.so
/usr/bin/ld: abort_.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: abort_.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: abort_.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

hate to bother you but any ideas?
happy xmas

Sorry to hear it doesn’t work as planned.
You can try and download my arm version of the file although I doubt it will work.
https://hemelmechanica.nl/share/spice.so.tgz
Happy Xmas to you too!

Hello

i have the file i will unzip and try in the the next day or so

thank you again