SpiceyPy Installing

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…
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:


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

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.
Happy Xmas to you too!


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

thank you again

Thank you all so much for this thread. I found phaseIV’s comments very helpful, but I needed to make several modifications to get this to work on my Pi3. Below are the steps I took. This is perhaps much more detail than is needed, but maybe it will help some future user:

  1. Install python packages
    –sudo apt-get install python3-pip
    –sudo apt-get install libatlas-base-dev
    –pip3 install numpy==1.18.1
    –pip3 install scipy==1.4.1
    –pip3 install setuptools wheel
    –pip3 install --no-clean spiceypy==3.1.1
    —the spiceypy installation will fail. Record the name of the tmp directory
  2. For my setup, Python packages are installed in ~/.local/lib/python3.7/site-packages/ This should be added to the PATH:
    – PATH=$PATH:/home/pi/.local/bin;export PATH
  3. Download naif-spice-2.25.gem from https://lunaserv.lroc.asu.edu/downloads.html
    – unpack this file, and unpack the data.tar.gz file.
    – locate the libcspice.a file in data/ext/lib/arm-linux-gnueabihf
  4. On the pi, unpack the libcspice.a file with: ar -x libcspice.a
  5. repack to spice.so: gcc -shared *.o -o spice.so
  6. copy spice.so to the path where spiceypy expects it
    (in my case, this was the tmp directory - replace pip-install-z__gvcje with the tmp directory used)
    sudo cp spice.so /tmp/pip-install-z__gvcje/spiceypy/spiceypy/utils
  7. cd to this directory and rebuild spiceypy:
    – python3 spiceypy build
    – python3 spiceypy install (this failed for me)
  8. copy the spiceypy file to the expected site_package directory
    cp -R /tmp/pip-install-z__gvcje/spiceypy/spiceypy ~/.local/lib/python3.7/site-packages/
  9. Test this by opening python and importing spiceypy:
    – python3
    – import spiceypy

SpiceyPy now supports ARM 64bit through the conda-forge just FYI, although I can see that the original posts were related to rpi3. SpiceyPy also can use an environment variable for the cspice.so file to simplify some of your steps