简体   繁体   中英

Failure to install packages via PyPi Mac - connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)

I tried to install textract package through PyPi on Mac, one requirement is to install pdftotext which required brew cask install. At least this is the earliest action I did that could remember. I kept getting this error message:

"pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”

I looked through every single answer to this type of error message on StackOverflow and tried out the follow without any luck:

$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
$ pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools

or reinstalling pip by

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

or add in config info or try easy install as a quickfix

easy_install pip==1.2.1
pip install --upgrade pip

I find the following solution worked and note it down in case anyone else may have this problem again and don't waste too much time. It appears to be an incompatibility issue on Brew install updated a python version and nothing to do with SSL certificate from PyPi. It relates to broken symlinks in the virtual environment; this can happen sometimes when you do a python upgrade using homebrew.

deactivate
cd ~/.virtualenvs/
find <your virenv>/ -type l -delete
virtualenv <your virenv>

use brew outdated to see which packages are going to be affected in next upgrade, if Python is included then wait until you know your venv is stable and working

nano ~/.bash_profile - opens bash

# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM