AndrewAnnex / SpiceyPy

SpiceyPy: a Pythonic Wrapper for the SPICE Toolkit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpiceyPy fails to install using pip in Mac OS X Big Sur

OrbitalMechanic opened this issue · comments

Describe the bug
SpiceyPy fails to install due to some SSL Certificate error

Expected behavior
Expected a successful installation.

To Reproduce
Used the following command for the installation from the command in a terminal window:
pip install spiceypy

Desktop (please complete the following information):

  • SpiceyPy Version 4.0.0
  • OS: Mac OSX Big Sur
  • OS Architecture: 64-bit
  • Python Version 3.8.5
  • Python Architecture: 64-bit

Additional context


(base) user@Mac-Pro ~ % pip install spiceypy
Collecting spiceypy
  Using cached spiceypy-4.0.0.tar.gz (265 kB)
Requirement already satisfied: numpy>=1.17.0 in ./opt/anaconda3/lib/python3.8/site-packages (from spiceypy) (1.19.2)
Building wheels for collected packages: spiceypy
  Building wheel for spiceypy (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/user/opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/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 /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-wheel-k8e180y7
       cwd: /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  Checking the path /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/cspice
  Unable to find CSPICE at /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/cspice. Attempting to Download CSPICE For you:
  Gathering information...
  SYSTEM:    Darwin
  PROCESSOR: i386
  MACHINE:   64bit
  Downloading CSPICE for MacIntel_OSX_AppleC_64bit...
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
  Unable to find CSPICE at /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/cspice. Exiting
  ----------------------------------------
  ERROR: Failed building wheel for spiceypy
  Running setup.py clean for spiceypy
Failed to build spiceypy
Installing collected packages: spiceypy
    Running setup.py install for spiceypy ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/user/opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-record-sc2n0qql/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/opt/anaconda3/include/python3.8/spiceypy
         cwd: /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/
    Complete output (19 lines):
    running install
    Checking the path /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/cspice
    Unable to find CSPICE at /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/cspice. Attempting to Download CSPICE For you:
    Gathering information...
    SYSTEM:    Darwin
    PROCESSOR: i386
    MACHINE:   64bit
    Downloading CSPICE for MacIntel_OSX_AppleC_64bit...
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Download failed with URLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123), trying again after 15 seconds!
    Unable to find CSPICE at /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/cspice. Exiting
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/user/opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-install-l4d81tc5/spiceypy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2r/4bw6nw0x58z0_ybx632_h14m0000gq/T/pip-record-sc2n0qql/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/opt/anaconda3/include/python3.8/spiceypy Check the logs for full command output.

The install command is failing when it goes to download SPICE from NAIF because it can't verify the authenticity of it. Do you have any institutional firewalls or anything that require special certificates?

You can manually download the OSX 64 bit spice tarball here: https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_64bit/packages/

Unzip it with tar -zxvf cspice.tar.Z, then you can tell spiceypy where to find it by setting the CSPICE_SRC_DIR environment variable prior to installing. For example I could download it into my home directory at /Users/jmapel/ and then unzip it and I would end up with /Users/jmapel/cspice/lib containing the cspice.a library. By setting CSPICE_SRC_DIR=/Users/jmapel/cspice prior to installing, cspice will find the library and properly copy it over to the install.

hey @OrbitalMechanic so if you are using anaconda you should install spiceypy using conda install spiceypy -c conda-forge instead of using pip. Otherwise this looks somewhat like the SSL handshake issue https://spiceypy.readthedocs.io/en/main/installation.html#ssl-alert-handshake-issue although I guess the error message is different. Try running conda list openssl to see if you are running an old version, then try upgrading/updating it to a newer version

Hi @AndrewAnnex, @OrbitalMechanic --

I have seen in the past a similar issue with Mac installs using pip, not only SpiceyPy but other packages that require SSL.
@OrbitalMechanic, could it be that you have downloaded Python from www.python.org but did not run the Install Certificates.command provided within the Python 3.8 folder in Applications?

In the cases I have seen, that fixed the issue.

@jdiazdelrio yeah that was my initial thought as well, but if you look at the text posted by @OrbitalMechanic the python executable is /Users/user/opt/anaconda3/bin/python unless they installed python from python.org and then moved the directory?

also the install certificates command is documented in the doc link above.

I would go with Andrew's recommendation to use Anaconda to install spiceypy instead of pip then.

Sam, just run "conda install spiceypy -c conda-forge" instead of these other suggestions. -Andrew

Sam,

The easiest and best solution would be to create a new conda environment for spiceypy conda create -n new_spiceypy_env python=3.8 spiceypy -c conda-forge that should just work.

Looking at the package conflicts my guess is that this is not a fresh conda environment, or that this is the base environment for anaconda which has lots of packages in it that are creating some conflict with packages that the conda-forge provides, which isn't easy to fix.
Otherwise the python version is not the issue.

That command should get you past whatever conflict issue is happening and the openssl issue. Here is a link https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html to anaconda's documentation that explains how to make new environments for reference.

For the other issue when trying to compile cspice, which again is unrelated to the main issue, it looks like you have not set up xcode properly. The solution to this is to run sudo xcode-select --install and ensure you can launch xcode locally before trying to install again, although you may need to restart the terminal.

As for the cause of the SSL error to begin with, thanks for posting the output for the ssl version. I don't have a great explanation for that yet as it seems like a relatively recent version of the library, maybe try conda installing ca-certificates? You might end up with the same conflict issues as before though. I would have to dig into it a bit more and try somethings out as I haven't had to think about these issues for a few years now.

let me know if the new environment command at the top of this message works.

thanks - Andrew

great! I'm closing the issue.