Closed mpitblado closed 7 months ago
The fix for this issue is to run the following install certificates command from within the virtual enviroment. This can be done by running the below in the root directory of the repo, while the virtual environment is activated. The below was found at https://gist.github.com/marschhuynh/31c9375fc34a3e20c2d3b9eb8131d8f3
# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module. Uses the certificates provided by the certifi package:
# https://pypi.python.org/pypi/certifi
import os
import os.path
import ssl
import stat
import subprocess
import sys
STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
| stat.S_IROTH | stat.S_IXOTH )
def main():
openssl_dir, openssl_cafile = os.path.split(
ssl.get_default_verify_paths().openssl_cafile)
print(" -- pip install --upgrade certifi")
subprocess.check_call([sys.executable,
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
import certifi
# change working directory to the default SSL directory
os.chdir(openssl_dir)
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
print(" -- removing any existing file or link")
try:
os.remove(openssl_cafile)
except FileNotFoundError:
pass
print(" -- creating symlink to certifi certificate bundle")
os.symlink(relpath_to_certifi_cafile, openssl_cafile)
print(" -- setting permissions")
os.chmod(openssl_cafile, STAT_0o775)
print(" -- update complete")
if __name__ == '__main__':
main()
Normally this file gets bundled with the manual installation of python from python.org, but in the case of creating from a virtual environment it doesn't seem to get copied over in some instances.
I forgot that I had also changed a few things in the code to get this to work. I will test if just running the above script is sufficient to fix the issue, or if the changes made were necessary. If the changes were necessary for the fix, I will draft a PR for review
Code changes do not seem to have been required beyond running the install certificates script. Closing!
This is likely something to do with my specific setup and will begin to troubleshoot, however I thought I would create an issue in case any other users experience the same error. I have checked the url that is being requested with curl and the certificate is loading fine, so perhaps something about the python virtual environment needs to be configured.
Error message presented
Potentially relevant code
./leafmachine/machine/fetch_data.py
Workaround
I believe that manually downloading the files from
https://leafmachine.org/LM2/
and placing them unzipped in the directory that the code is looking in should solve this issue, asif ver['version'] == VERSION:
should be true.