Probleme beim Löschen von Cache in PythonPython

Python-Programme
Anonymous
 Probleme beim Löschen von Cache in Python

Post by Anonymous »

Ich habe Python -Code, der Astroquery verwendet, das seit 2 Jahren arbeitet, aber jetzt einen Fehlercode (unten kopiert) angibt, was vorschlägt, dass das SSL -Zertifikat für NASA Horizons veraltet ist. Ich schrieb an diejenigen, die die Datenbank der NASA Horizons verwalten und sagten, dass ein altes Zertifikat irgendwo in meinem Cache steckt. Ich kann nicht finden, wo das ist, und ich habe das gleiche Problem auf zwei Maschinen, auf denen ich den Code ausgeführt habe. Einer ist ein Mac, das andere ein Windows -System. Ich kann keine Cache -Dateien auf einem finden, die sich auf Horizonte, Astroquery oder Python -Dateien beziehen. Kann jemand vorschlagen, dass Orte nachsehen? um völlig uninformativ zu sein. < /p>

Code: Select all

from astroquery.jplhorizons import Horizons
target = Horizons(id=299, location=662, epochs=[{'2025-02-06 01:47:13'}])
print(target)
eph = target.ephemerides()
< /code>
JPLHorizons instance "299"; location=662, epochs=[{'2025-02-06 01:47:13'}], id_type=None
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connection.py", line 370, in connect
ssl_context=context)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
< /code>
Edit 2: I have added "Horizons.clear_cache()" to the code, and it made no difference.
Update: Further correspondence with NASA revealed the SSL certificate that they renewed and installed (on all public facing services) is from Entrust. Google and others decided they would block all Entrust SSL certificates that were issued after November 2024 due to not trusting Entrust. This was later resolved but only if you have an up-to-date OS.
NASA indicated that if a web query of NASA Horizons worked then using astroquery in python should work as well. It did not. The solution required updating the certifi.ca in python itself.
On the windows machine that has python installed through Anaconda, I had to go to the Anaconda Navigator, then select environments, then do a search for all 'updatable' instances matching 'certifi'. Once these were updated everything worked.
On the Mac that had python installed through pip, this was the solution"
Enter python, then:
>>> from requests.utils import DEFAULT_CA_BUNDLE_PATH
>>> print(DEFAULT_CA_BUNDLE_PATH)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/certifi/cacert.pem
>>> exit()
< /code>
That tells you what is out of date.
Exit python, then:
machine: user$ pip3 install certifi --upgrade

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post