Issues installing packages

Answered

Using the project interpreter to install packages. Trying to install ssl i get:

******************************************************

Collecting ssl
Could not fetch URL https://pypi.python.org/simple/ssl/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777) - skipping

Could not find a version that satisfies the requirement ssl (from versions: )
No matching distribution found for ssl

******************************************************

I am getting this [SSL: CERTIFICATE_VERIFY_FAILED]  warning no matter where I try things, windows prompt, inside python. I am also getting the error when I try to run a python script inside pycharm.

 

Any help would be appreciated.

 

23 comments

Hi there,

It seems that your system can't verify SSL certificate of pypi.python.org, most likely because it lacks the certificate of its CA for some reason. Is it possible to access other resources using HTTPS like github.com:

$ python -c "import urllib; print(urllib.urlopen('https://github.com').code)"? 

Why are you trying to install ssl package in the first place (instead of the standard one)? Which version of Python do you use?

0

Python 3.6.3

I can't install anything. I ended up permanently bypassing the SSL check by creating a pip configuration file in the directory:

$HOME/.config/pip/pip.conf

 

It contains the lines:

[global]
trusted-host = pypi.python.org
 
Obviously not a good solution.
I can't seem to install anything without having the issue without adding the host as a trusted host.
0

Same here. I'm behind a Corporate firewall at my day job, I'm using PyCharm for Windows there and the odds are high that that there is also a Web proxy. Is there a way to install the Pypi certificate in the app? I see tools->server certificates, but I don't know how to do download and install the correct certificate.

0

Hi John,

No, unfortunately, certificates imported there affect only network connections made from JVM, while pip is launched in an independent Python process. I believe that using "trusted-host" and "cert" options of a configuration file is the only solution at the moment.

0

trusted host in Paycharm preferences didn't work. how do you implement a configuration file?

0

I've just installed a new firewall that does SSL inspection. I'm now getting the "SSL: CERTIFICATE_VERIFY_FAILED" error whenever I try to install packages. I took a look at https://stackoverflow.com/questions/39356413/how-to-add-a-custom-ca-root-certificate-to-the-ca-store-used-by-python-in-window and created an environment variable called SSL_CERT_DIR so that:

python -c "import ssl; print(ssl.get_default_verify_paths())"

Outputs:

DefaultVerifyPaths(cafile=None, capath='C:\\Users\\asmith\\SSL', openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/usr/local/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/usr/local/ssl/certs')

and

echo %SSL_CERT_DIR%

Outputs:

C:\Users\asmith\SSL

I've put my CA root certificate into C:\Users\asmith\SSL but I still get the error… :-/ 

I'm using I'm using PyCharm Professional 2018.1.4 on Windows 10. Any other ideas? Thanks!

0

Hi Alex,

Are you sure that environment variable SSL_CERT_DIR is properly visible to PyCharm? Normally, you need to relaunch the IDE to apply changes in the environment. You can enable debug logging for "#com.intellij.execution.configurations.GeneralCommandLine" in Help | Debug Log Settings... and check in idea.log whether this variable is actually used when we launch pip to install a package. By the way, can you install packages outside of PyCharm with this setup?

1

Thanks Mikhail!

Here's what the log says is executing:

  • 2018-07-10 10:26:58,071 [ 118682]  DEBUG - figurations.GeneralCommandLine - Executing [C:\Pythob27\python.exe "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\packaging_tool.py" install --build-dir C:\Users\asmith\AppData\Local\Temp\pycharm-packaging -U Pillow==5.2.0] 
  • 2018-07-10 10:26:58,071 [ 118682]  DEBUG - figurations.GeneralCommandLine -   environment: {PYTHONDONTWRITEBYTECODE=1, PYTHONUNBUFFERED=1} (+CONSOLE)
  • 2018-07-10 10:26:58,071 [ 118682]  DEBUG - figurations.GeneralCommandLine -   charset: windows-1252

So it doesn't appear to be using SSL_CERT_DIR there, although it appears elsewhere in the log file eg:

  • 2018-07-10 10:27:12,319 [ 132930]  DEBUG - figurations.GeneralCommandLine - Executing [C:\Pythob27\python.exe "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\syspath.py"]

  • 2018-07-10 10:27:12,320 [ 132931]  DEBUG - figurations.GeneralCommandLine -   environment: {NUMBER_OF_PROCESSORS=8, CommonProgramFiles=C:\Program Files\Common Files, Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Pythob27\;C:\Pythob27\Scripts;C:\Pythob27\Lib\site-packages\PyQt4;C:\Python27\Lib\site-packages\PyQt4;C:\Python27\;C:\Python27\Scripts;C:\Python34\Lib\site-packages\PyQt5;C:\Python34\;C:\Python34\Scripts;C:\Python35\Scripts\;C:\Python35\;C:\ProgramData\Oracle\Java\javapath;

    ProgramFiles=C:\Program Files, PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 26 Stepping 5, GenuineIntel, TEMP=C:\Users\asmith\AppData\Local\Temp, PYTHONDONTWRITEBYTECODE=1, SystemDrive=C:, SSL_CERT_DIR=C:\Users\asmith\SSL, LOGONSERVER=\\LS-IT, USERDOMAIN=LS-IT, TMP=C:\Users\asmith\AppData\Local\Temp, HOMEPATH=\Users\asmith, SystemRoot=C:\WINDOWS, ADSK_CLM_WPAD_PROXY_CHECK=FALSE, OS=Windows_NT, =::=::\, USERNAME=asmith, USERDOMAIN_ROAMINGPROFILE=LS-IT, CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files, LOCALAPPDATA=C:\Users\asmith\AppData\Local, VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\, DXVCL=C:\Program Files\Developer Express.VCL, APPDATA=C:\Users\asmith\AppData\Roaming, HOMEDRIVE=C:, ALLUSERSPROFILE=C:\ProgramData, FP_NO_HOST_CHECK=NO, PYTHONPATH=C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers, PROCESSOR_LEVEL=6, ProgramData=C:\ProgramData, ComSpec=C:\WINDOWS\system32\cmd.exe, PROCESSOR_ARCHITECTURE=AMD64, PROCESSOR_REVISION=1a05, PSModulePath=%ProgramFiles%\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\, COMPUTERNAME=LS-IT, PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW, ProgramFiles(x86)=C:\Program Files (x86), USERPROFILE=C:\Users\asmith, CommonProgramW6432=C:\Program Files\Common Files, ProgramW6432=C:\Program Files, VISUALSVN_SERVER=C:\Program Files (x86)\VisualSVN Server\, windir=C:\WINDOWS, PUBLIC=C:\Users\Public, asl.log=Destination=file, Python=C:\Users\asmith\AppData\Local\Programs\Python\Python35\} (+CONSOLE) 

Here's what happens when I install packages via the command line, with and without using my certificate:

C:\Users\asmith>pip install -U Pillow==5.2.0
Collecting Pillow==5.2.0
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)'),)': /simple/pillow/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)'),)': /simple/pillow/
Could not fetch URL https://pypi.org/simple/pillow/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pillow/ (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)'),)) - skipping
Could not find a version that satisfies the requirement Pillow==5.2.0 (from versions: )
No matching distribution found for Pillow==5.2.0
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)'),)) - skipping

C:\Users\asmith>pip install -U Pillow==5.2.0 --cert=C:\Users\asmith\SSL\teco-ca.crt
Collecting Pillow==5.2.0
Downloading https://files.pythonhosted.org/packages/86/25/711c867ea0685b5fc3ec7c954e7d3a43d7420cb98646bec2b46fa7600f2e/Pillow-5.2.0-cp27-cp27m-win32.whl (1.3MB)
100% |################################| 1.3MB 2.8MB/s
Installing collected packages: Pillow
Found existing installation: Pillow 5.0.0
Uninstalling Pillow-5.0.0:
Successfully uninstalled Pillow-5.0.0
Successfully installed Pillow-5.2.0

So if I can just figure out how to get it to add --cert=C:\Users\asmith\SSL\teco-ca.crt when it installs, I should be sorted :)

0

Hmm, interesting. Have you tried SSL_CERT_FILE variable instead to specify a path to a single file?

Also, I believe that the bulletproof option here is to set "cert" setting in one of the configuration files used by pip like e.g.

[global]

cert=C:\Users\asmith\SSL\teco-ca.crt

1

I can't find any pip.ini file on my computer and there are lots of pip directories:

I created a C:\Users\asmith\AppData\Local\pip.ini with

[global]

cert=C:\Users\asmith\SSL\teco-ca.crt

restarted IDE but still get the same error.

0

I believe it should be pip/pip.ini (with additional "pip" directory) according to the link to pip documentation that I gave. Please double check the paths.

0

Sorry, that was my typo, I was trying:

C:\Users\asmith\AppData\Local\pip\pip.ini

But that doesn't work.

I appreciate your help a lot. At the same time, do you know if it's possible for PyCharm Professional users to open support tickets with JetBrains directly or is the community forum the only way to get help?

0

Are you sure that "C:\Users\asmith\AppData\Local", not "C:\Users\asmith\AppData\Roaming", is the right directory to put "pip/pip.ini" in? Is it the path where %APPDATA% points to?

1

> At the same time, do you know if it's possible for PyCharm Professional users to open support tickets with JetBrains directly or is the community forum the only way to get help?

You could submit a new support request to PyCharm technical support here: https://intellij-support.jetbrains.com/hc/en-us/requests/new or send an e-mail with a problem description to pycharm-support@jetbrains.com. Also you could file issues/bug reports directly to Pycharm issue tracker: https://youtrack.jetbrains.com/issues/PY.

1

Sorry for the delay Mikhail, I've been away on leave. There was a "pip" directory in "C:\Users\asmith\AppData\Local" but none in "C:\Users\asmith\AppData\Roaming", which is why I'd put the ini in the former. However, I just checked %APPDATA% and it actually points to the latter… So I've put the ini in there and it fixed it! Thanks!!

 

Thanks Anna, I'll keep that in mind if I get stuck in the future. 

0

Hello, I hate to say this but me too ....

I've been working mostly in Py2.7 for many years and have no problem ... I decided to upgrade and install Anaconda for Py 3.7 so I now have both 2.7 and 3.7 on my *Windows* 10 machine, I run PyCharm 2018.3.3 Community Ed.

I tried installing some packages (work fine in 2.7) ... get the failure in 3.7 below.

I tried installing the %APPDATA%/pip/pip.ini with:

[global]
trusted-host = pypi.python.org

I tried a bunch of stuff ... seems the openssl issue that started in Python 3.6 is killing me, actually driving me crazy and wondering why I decided to move to Python 3.7 after all these years.

Any help appreciated .... wanting to go back to 2.7.X .... yeah, I know this is weak!

error I get from inside PyCharm/cmd line when running pip directly"

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Could not find a version that satisfies the requirement smartsheet-python-sdk (from versions: )
No matching distribution found for smartsheet-python-sdk
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

 

0

Hi,

I added the -vvv pip option to PyCharm's 

pip install -vvv smartsheet-python-sdk==1.3.3

 

* https://pypi.org/simple/pip/
Getting page https://pypi.org/simple/pip/
Looking up "https://pypi.org/simple/pip/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/smartsheet-python-sdk/
Could not find a version that satisfies the requirement smartsheet-python-sdk==1.3.3 (from versions: )
No matching distribution found for smartsheet-python-sdk==1.3.3
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

0

Hi Craig,

 

Which exact version of Anaconda do you use? On the whole, it looks like a recent problem with their Python distribution specifically. You can try one of the workarounds mentioned in the corresponding thread: for instance, downgrading Conda to 4.5.11 or installing ssl module manually.

0

My apologies for butting in - I may have a similar SSL problem.

I've been running Python scripts for 10+ years but am still very basic (kinda an oldie-newbie!)

After a massive hardware failure, I had to do a complete re-install of my entire system (had good backups, so nothing lost)

My new python setup is different than the one that had been working just fine.

I first install Anaconda (python 3.7.2), then installed PyCharm

OpenSSL appears in the list of installed packages in Anaconda Navigator in both environments.

openssl (1.1.1a) and pyopenssl (18.0.0) both appear in the Project Interpreter package list.

Running my script give "SSLError("Can't connect to HTTPS URL because the SSL module is not available." apparently from " File "C:\Users\D\Anaconda3\envs\Jan19\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request)

I've been trying every suggestion that I could find, to no avail!

Did I get nailed by some recent Win10 update???

Any suggestions would be appreciated - TIA

Doug

 

 

0

Update !!!MIRACLE!!! (after a week of attempts)

My script now works!

The only changes I made:

Executed Win64OpenSSL_Light-1_1_1a from https://slproweb.com/products/Win32OpenSSL.html (I'd had 1.1.0j already)

Added C:\OpenSSL-Win64 to my PATH (I'd had C:\OpenSSL-Win64\bin already)

Hope this helps someone!

Cheers, Doug

1

ljdsangs comment regarding installing OpenSSL_Light worked for me first try!

0

Anyone who have SSL issues with Anaconda/miniconda, you can try the workaround mentioned in the following ticket:

https://youtrack.jetbrains.com/issue/PY-33527

Also, we are close to new release with a some major fixes related to Conda activation.

0

Please sign in to leave a comment.