OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Virtual Environment Making Astroquery Gaia Search Fail

  • Thread starter Thread starter Hunter Brooks
  • Start date Start date
H

Hunter Brooks

Guest
I am using astroquery to search through the Gaia catalog. However, I am using a MacOS local venv which is causing it to fail. I tested my code without the venv activated and it works as intended. I need to use this virtual environment sadly.

Why does my astroquery code break when using a venv?

Code:

Code:
def gaia_table(ra, dec, radius): 
  #Makes the SQL code to run it into the GAIA search
  query = "SELECT TOP 2000 \
  gaia_source.ra,gaia_source.dec,gaia_source.ra_error,gaia_source.phot_g_mean_flux_error,gaia_source.phot_bp_mean_flux_error,gaia_source.phot_rp_mean_flux_error,gaia_source.ref_epoch,gaia_source.dec_error,gaia_source.parallax,gaia_source.parallax_error,gaia_source.radial_velocity,gaia_source.radial_velocity_error,gaia_source.pmra,gaia_source.pmra_error,gaia_source.pmdec,gaia_source.pmdec_error,gaia_source.phot_g_mean_mag,gaia_source.phot_bp_mean_mag,gaia_source.phot_rp_mean_mag,gaia_source.phot_g_mean_flux,gaia_source.phot_bp_mean_flux,gaia_source.phot_rp_mean_flux \
  FROM gaiadr3.gaia_source \
  WHERE \
  CONTAINS( \
  POINT('ICRS',gaiadr3.gaia_source.ra,gaiadr3.gaia_source.dec), \
  CIRCLE('ICRS', " + str(ra) + "," + str(dec) + "," + str(((radius/2) * 0.000277778) - 0.000277778)+ ")" \
  ")=1"

  #Run this SQL query on the online GAIA database
  job = Gaia.launch_job_async(query)
  results = job.get_results()
  return results

Error:

Code:
  File "WRAP.py", line 981, in gaia_table
    job = Gaia.launch_job_async(query)
  File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/gaia/core.py", line 903, in launch_job_async
    return TapPlus.launch_job_async(self, query=query,
  File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/core.py", line 409, in launch_job_async
    response = self.__launchJob(query,
  File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/core.py", line 625, in __launchJob
    response = self.__connHandler.execute_tappost(subcontext=context,
  File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/conn/tapconn.py", line 273, in execute_tappost
    return self.__execute_post(context, data, content_type, verbose)
  File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/conn/tapconn.py", line 426, in __execute_post
    conn.request("POST", context, data, self.__postHeaders)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 950, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1424, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)
<p>I am using astroquery to search through the Gaia catalog. However, I am using a MacOS local venv which is causing it to fail. I tested my code without the venv activated and it works as intended. I need to use this virtual environment sadly.</p>
<p>Why does my astroquery code break when using a venv?</p>
<p>Code:</p>
<pre><code>def gaia_table(ra, dec, radius):
#Makes the SQL code to run it into the GAIA search
query = "SELECT TOP 2000 \
gaia_source.ra,gaia_source.dec,gaia_source.ra_error,gaia_source.phot_g_mean_flux_error,gaia_source.phot_bp_mean_flux_error,gaia_source.phot_rp_mean_flux_error,gaia_source.ref_epoch,gaia_source.dec_error,gaia_source.parallax,gaia_source.parallax_error,gaia_source.radial_velocity,gaia_source.radial_velocity_error,gaia_source.pmra,gaia_source.pmra_error,gaia_source.pmdec,gaia_source.pmdec_error,gaia_source.phot_g_mean_mag,gaia_source.phot_bp_mean_mag,gaia_source.phot_rp_mean_mag,gaia_source.phot_g_mean_flux,gaia_source.phot_bp_mean_flux,gaia_source.phot_rp_mean_flux \
FROM gaiadr3.gaia_source \
WHERE \
CONTAINS( \
POINT('ICRS',gaiadr3.gaia_source.ra,gaiadr3.gaia_source.dec), \
CIRCLE('ICRS', " + str(ra) + "," + str(dec) + "," + str(((radius/2) * 0.000277778) - 0.000277778)+ ")" \
")=1"

#Run this SQL query on the online GAIA database
job = Gaia.launch_job_async(query)
results = job.get_results()
return results
</code></pre>
<p>Error:</p>
<pre class="lang-none prettyprint-override"><code> File "WRAP.py", line 981, in gaia_table
job = Gaia.launch_job_async(query)
File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/gaia/core.py", line 903, in launch_job_async
return TapPlus.launch_job_async(self, query=query,
File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/core.py", line 409, in launch_job_async
response = self.__launchJob(query,
File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/core.py", line 625, in __launchJob
response = self.__connHandler.execute_tappost(subcontext=context,
File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/conn/tapconn.py", line 273, in execute_tappost
return self.__execute_post(context, data, content_type, verbose)
File "/Users/Documents/GitHub/WRAP/wrap_mac/lib/python3.8/site-packages/astroquery/utils/tap/conn/tapconn.py", line 426, in __execute_post
conn.request("POST", context, data, self.__postHeaders)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1424, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)
</code></pre>
 

Latest posts

Top