1

I got an error of

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

Then I saw a solution from Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org (click the certificate file). However it occurs an error. I've tried to upgrade pip and add --user after install the module, but still failed.

.
.
.
Installing collected packages: certifi
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/certifi'
Consider using the `--user` option or check the permissions.

WARNING: Ignoring invalid distribution -ip (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)
WARNING: Ignoring invalid distribution -ip (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)
WARNING: Ignoring invalid distribution -ip (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

[notice] A new release of pip available: 22.1.2 -> 22.2.1
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "<stdin>", line 44, in <module>
  File "<stdin>", line 24, in main
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8', '-E', '-s', '-m', 'pip', 'install', '--upgrade', 'certifi']' returned non-zero exit status 1.
.
.
.

Edit I try to do something, the above error is disappeared, but it shows another error

ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/certifi' Consider using the `--user` option or check the permissions.

I know that I can add user in the last(e.g. pip3 install module --user), but this is the one to click the files, not typing the command. Then how to do it?

I appreciate all your help. Thanks

M.pillow
  • 75
  • 8
  • it shows problem with `_ssl.c` and this can means C/C++ library `OpenSSL` which you have to download and install on your own - it is NOT python module. Page [OpenSSL.org](https://www.openssl.org/) – furas Jul 31 '22 at 16:31
  • @furas, does it mean i need to download OpenSSL module in python? – M.pillow Jul 31 '22 at 16:42
  • it is NOT python module but C/C++ library (and `urllib` and other Python modules may use them) but you have you download new version and reinstall it in system on your own (not using `pip`). – furas Jul 31 '22 at 16:49
  • new version of library `openssl` – furas Jul 31 '22 at 16:50
  • @furas SOOOO hard for a beginner! – M.pillow Jul 31 '22 at 16:51
  • Do i need to create in a virtual environment? – M.pillow Jul 31 '22 at 16:51
  • as I said it is NOT python module - virttual environment is totally useless for non-python liraries. – furas Jul 31 '22 at 16:53
  • ok, so just doing in ```name@MMforfunmac2 ~ % pip3 install pyOpenSSL```? – M.pillow Jul 31 '22 at 16:58
  • `pyOpenSSL` is only python wrapper on C/C++ library `OpenSSL` but it still may need to install newer version of `OpenSSL`. Module `pyOpenSSL` may not install it. – furas Jul 31 '22 at 17:09
  • @furas, I installed ```brew install openssl```. But I am confuse about it now. – M.pillow Jul 31 '22 at 17:20
  • I am in python environment, so the way is to install ```pyOpenSSL``` instead of ```OpenSSL```, right? – M.pillow Jul 31 '22 at 17:21
  • you are wrong. `OpenSSL` is NOT replacement of `pyOpenSSL`. `pyOpenSSL` is wrapper on `OpenSSL` and you need both. it works as `your code -> pyOpenSSL (Python module) -> OpenSSL (C/C++ library) -> system` – furas Jul 31 '22 at 20:29
  • OH,okay. I installed all of it. But I got an error of ```ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/certifi' Consider using the `--user` option or check the permissions. ``` – M.pillow Aug 01 '22 at 01:16
  • I know that I can add user in the last(e.g. pip3 install module --user), but this is the one to click the files, not typing the command. Then how to do it? – M.pillow Aug 01 '22 at 01:17
  • it may need to use `sudo ....` to run it as admin/root – furas Aug 01 '22 at 01:31
  • @furas You mean ```sudo pip3 install certifi```? I've tried it but still failed – M.pillow Aug 01 '22 at 01:35
  • I'll open a new question – M.pillow Aug 01 '22 at 01:37
  • do you exactly the same error when you run with sudo? If you have different error then you have different problem. – furas Aug 01 '22 at 09:23

1 Answers1

0

You're trying to install packages into your System Python. Don't do this. Create a virtualenv for your project, then install libraries into that

python -m venv venv
source venv/bin/activate
pip install --user -U pip certifi
python app.py # run your code 
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Cool, so do i need to do all the things inside the venv environment? – M.pillow Jul 31 '22 at 16:31
  • I built a virtual envi. like this ```(venv) name@MMforfunmac2 ~ % ```, but I got the same error when i type pip install XXX – M.pillow Jul 31 '22 at 16:36
  • The error should no longer include `/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages` since it should use the local environment... Did you try with `--user` again? – OneCricketeer Aug 01 '22 at 16:47