linkml / archived-linkml-model-template

DEPRECATED! Please use linkml-project-cookiecutter instead.
10 stars 6 forks source link

Bug: issue during setup: `SSL: CERTIFICATE_VERIFY_FAILED` #15

Closed joeflack4 closed 1 year ago

joeflack4 commented 3 years ago

Description

During setup, after using make, the following error happens.

Error

Short error message

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

Long error message

make
mkdir -p model/docs
cp -R model/docs/*.md target/docs
# mkdocs.yml moves from the target/docs to the docs directory
export PIPENV_VENV_IN_PROJECT=true && export PIPENV_PIPFILE=make-venv/Pipfile && export PIPENV_IGNORE_VIRTUALENVS=1 && pipenv run mkdocs build
WARNING  -  Config value: 'site_url'. Warning: This option is now required. Set to a valid URL or an empty string to avoid an
  error in a future release.
WARNING  -  Config value: 'site_url'. Warning: The 'use_directory_urls' option has been disabled because 'site_url' contains an
  empty value. Either define a valid URL for 'site_url' or set 'use_directory_urls' to False.
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /Users/joeflack4/projects/linkml-test-template/docs
INFO     -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
  Boolean.md
INFO     -  Documentation built in 0.98 seconds
rm -rf target/json
mkdir -p target/json
export PIPENV_VENV_IN_PROJECT=true && export PIPENV_PIPFILE=make-venv/Pipfile && export PIPENV_IGNORE_VIRTUALENVS=1 && pipenv run gen-jsonld --log_level WARNING --no-mergeimports model/schema/sample_model.yaml > target/json/sample_model.json
mkdir -p linkml_test_template/json
cp target/json/sample_model.json linkml_test_template/json/sample_model.json
rm -rf target/rdf
mkdir -p target/rdf
export PIPENV_VENV_IN_PROJECT=true && export PIPENV_PIPFILE=make-venv/Pipfile && export PIPENV_IGNORE_VIRTUALENVS=1 && pipenv run gen-rdf --log_level WARNING --context /Users/joeflack4/projects/linkml-test-template/linkml_test_template/jsonld/sample_model.context.jsonld model/schema/sample_model.yaml > target/rdf/sample_model.ttl
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1346, in do_open
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1257, in request
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1303, in _send_request
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1252, in endheaders
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1012, in _send_output
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 952, in send
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1426, in connect
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 500, in wrap_socket
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1040, in _create
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/bin/gen-rdf", line 8, in <module>
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/click/core.py", line 782, in main
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/linkml/generators/rdfgen.py", line 58, in cli
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/linkml/utils/generator.py", line 132, in serialize
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/linkml/generators/rdfgen.py", line 43, in end_schema
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib/graph.py", line 1078, in parse
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib_jsonld/parser.py", line 95, in parse
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib_jsonld/parser.py", line 107, in to_rdf
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib_jsonld/parser.py", line 125, in parse
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib_jsonld/context.py", line 200, in load
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib_jsonld/context.py", line 213, in _prep_sources
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib_jsonld/util.py", line 23, in source_to_json
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib/parser.py", line 193, in create_input_source
  File "/Users/joeflack4/projects/linkml-test-template/make-venv/.venv/lib/python3.9/site-packages/rdflib/parser.py", line 113, in __init__
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 517, in open
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 534, in _open
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1389, in https_open
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1349, in do_open
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>
make: *** [target/rdf/sample_model.ttl] Error 1

Solution

I found a solution that worked for me: https://stackoverflow.com/questions/44649449/brew-installation-of-python-3-6-1-ssl-certificate-verify-failed-certificate/44649450#44649450

The fix involves running the attached python file (when the linkml-model-template env is activated). fix.py.zip

Note that the fix says "Python 3.6 installed via homebrew", but I am actually using Python 3.9 directly from python.org.

What to do next

I have not created a pull request for this, because I do not fully understand why this solution works, nor do I know for sure if it is safe. I imagine there is a simpler, better solution than this strange ad-hoc fix. @jiaola Maybe we can discuss a better fix for this issue?

noelmcloughlin commented 3 years ago

I think best PR solution is to present the Error message and state

"Python must be correctly installed on MacOS; see https://bugs.python.org/msg388144 ".

Note: To compound the MacOS story, the Homebrew python package is missing "Install Certificates.command" command, but even when that packaging bug is fixed, https://bugs.python.org/msg388144 is still valid.

joeflack4 commented 2 years ago

Interesting. I have Python installed on my computer and have had several versions of it installed for years. As I mentioned in the OP, I'm using 3.9 here downloaded from Python.org. But yeah, Python is no stranger to these kinds of cryptic issues in various environments.

sierra-moxon commented 1 year ago

This repo is archived. Equivalent functionality is now hosted at http://linkml/linkml-project-cookiecutter/. If we close an issue you still are waiting on, please feel free to reach out on the issue tracker and we will add it to the cookie-cutter. https://github.com/linkml/linkml/issues.