Pipenv: [11.6.7] SSL Error when locking

Created on 13 Mar 2018  路  28Comments  路  Source: pypa/pipenv

Be sure to check the existing issues (both open and closed!).

This looks like the same issue as #1707, which says that 11.6.3 fixes the issue. But I'm seeing it with 11.6.7.

When attempting to run pipenv lock, I'm getting an SSLError "No such file or directory". Full stack trace below (I ran pipenv lock -v to get the full set of stack traces, but omitted the resolution output, which seemed to work fine).

I tried the workaround listed in #1707 (pip install certifi) with no luck ("Requirement already satisfied" and no change in behavior).


$ python -m pipenv.help output
Pipenv version: '11.6.7'

Pipenv location: 'C:\\Python36\\lib\\site-packages\\pipenv'

Python location: 'C:\\Python36\\python.exe'

Other Python installations in PATH:

  • 3.6: C:\Python36\python.exe

  • 3.6.4: C:\Python36\python.exe

  • 3.6.4: C:\Users\rcoulman\AppData\Local\Programs\Python\Launcher\py.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.4',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '7',
 'platform_system': 'Windows',
 'platform_version': '6.1.7601',
 'python_full_version': '3.6.4',
 'python_version': '3.6',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • ASL.LOG
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • FP_NO_HOST_CHECK
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • NUMBER_OF_PROCESSORS
  • OS
  • PATH
  • PATHEXT
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PSMODULEPATH
  • PUBLIC
  • SESSIONNAME
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • TVT
  • USERDNSDOMAIN
  • USERDOMAIN
  • USERNAME
  • USERPROFILE
  • WINDIR
  • WINDOWS_TRACING_FLAGS
  • WINDOWS_TRACING_LOGFILE
  • PIP_PYTHON_PATH
  • PYTHONUNBUFFERED

Pipenv-specific environment variables:

Debug-specific environment variables:

  • PATH: %SystemRoot%\system32\WindowsPowerShell\v1.0\;%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\ProgramData\ Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\ ;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\QuickTime\Q TSystem\;C:\Program Files (x86)\Bitvise SSH Client;C:\Python36\Scripts\;C:\Python36\;C:\Users\rcoulman\AppData\Local\Pro grams\Python\Launcher\;C:\Users\rcoulman\AppData\Roaming\Python\Python36\Scripts;C:\Ruby25-x64\bin;C:\Users\rcoulman\App Data\Local\atom\bin;C:\Users\rcoulman\AppData\Local\Programs\Git\cmd

Contents of Pipfile ('C:\Users\rcoulman\src\py_spike\Pipfile'):

[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"


[packages]

canopen = "~= 0.5.1"
hats = {git = "git@dev-git02:hats", editable = true}


[dev-packages]

"autopep8" = "~= 1.3"
"flake8" = "~= 3.5"
pytest = "~= 3.4"
pytest-watch = "~= 4.1"


[requires]

python_version = "3.6"


[pipenv]

keep_outdated = true


Expected result

I expected the pipenv lock command to complete successfully.

Actual result


Full Stack Trace
Traceback (most recent call last):
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\packages\urllib3\util\ssl_.py", line 295, in
ssl_wrap_socket
context.load_verify_locations(ca_certs, ca_cert_dir)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\adapters.py", line 423, in send
timeout=timeout
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\packages\urllib3\connectionpool.py", line 595
, in urlopen
chunked=chunked)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\packages\urllib3\connectionpool.py", line 352
, in _make_request
self._validate_conn(conn)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\packages\urllib3\connectionpool.py", line 831
, in _validate_conn
conn.connect()
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\packages\urllib3\connection.py", line 289, in
connect
ssl_version=resolved_ssl_version)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\packages\urllib3\util\ssl_.py", line 297, in
ssl_wrap_socket
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\python36\lib\site-packages\pipenv\resolver.py", line 66, in
main()
File "c:\python36\lib\site-packages\pipenv\resolver.py", line 54, in main
results = resolve(packages, pre=do_pre, sources=project.sources, verbose=is_verbose, clear=do_clear)
File "c:\python36\lib\site-packages\pipenv\resolver.py", line 52, in resolve
return pipenv.utils.resolve_deps(packages, which, project=project, pre=pre, sources=sources, clear=clear, verbose=ve
rbose)
File "c:\python36\lib\site-packages\pipenv..pipenv\utils.py", line 429, in resolve_deps
r = requests.get('https://pypi.org/pypi/{0}/json'.format(name), timeout=10)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\sessions.py", line 488, in get
return self.request('GET', url, *kwargs)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\sessions.py", line 475, in request
resp = self.send(prep, *
send_kwargs)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "c:\python36\lib\site-packages\pipenv..pipenvvendor\requests\adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 2] No such file or directory

Steps to replicate

Using Pipfile from above details, run pipenv.lock. There is a private git dependency in there; that one can be safely omitted from the Pipfile and the error will still occur.

Needs More Information Possible Bug

All 28 comments

Hmm, I cannot replicate this.

We're shipping the ca bundle properly.

I see no reason for this to be happening.

Ah, Windows. Let me try it there.

Also can't replicate this on windows.

Anything I can try to help track this down?

Run > python:

>>> from pipenv.vendor.pip9._vendor.requests.certs import where
>>> print(where())
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pipenv.vendor.pip9._vendor.requests.certs import where
>>> print(where())
C:\Users\rcoulman\AppData\Roaming\Python\Python36\site-packages\certifi\cacert.pem

and I have confirmed that the pem file is present in that location.

hmmmm

okay so you need to cd into C:\Users\rcoulman\AppData\Roaming\Python\Python36\site-packages\, then run a different python interpreter, like python2.

Then import pipenv, and run the same where() function.

I don't have any other Python interpreters on this machine, and I'd rather not install any unless that's the only way to fix this issue.

you can create a virtualenv and use that python interpreter

the goal is to run a "pure" python without pipenv installed in its site-packages :)

oh, so go to a project, and then run pipenv shell

then cd to that directory, and import pipenv

PS C:\Users\rcoulman\src\my_project> pipenv shell
Launching subshell in virtual environment. Type 'exit' to return.
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\rcoulman\src\my_project> cd ..\..\AppData\Roaming\Python\Python36\site-packages
PS C:\Users\rcoulman\AppData\Roaming\Python\Python36\site-packages\certifi> python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pipenv.vendor.pip9._vendor.requests.certs import where
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pipenv'

Sorry, that was from the wrong directory :-(. Here's the right one:

PS C:\Users\rcoulman\src\my_project> pipenv shell
Launching subshell in virtual environment. Type 'exit' to return.
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\rcoulman\src\my_project> cd ..\..\AppData\Roaming\Python\Python36\site-packages
PS C:\Users\rcoulman\AppData\Roaming\Python\Python36\site-packages> python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pipenv.vendor.pip9._vendor.requests.certs import where
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pipenv.vendor'

hmm, we may have paths a little wrong.

@kennethreitz Is there more you need me to do here? Did I get you the information you need, or did I do it wrong?

This seems to be fixed for me in 11.7.4.

Spoke too soon; I did the upgrade from within a virtualenv and it was working, but when I got back out of the virtualenv and re-upgraded pipenv, it was failing again :-(.

it sounds like you have a messed up python installation

please uninstall all your pipenvs in all your venvs and just install it once, as intended.

@randycoulman Did you resolve the issue? I am facing the same error on the command pipenv lock. It's my first time using pipenv. I was trying to install django when the issue surfaced. I am using Python 3.6.4 on Windows 10 64-bit machine with pipenv version 11.7.3

@AlphaSoldier I completely uninstalled Python and all virtualenvs, etc. from my box, then reinstalled and everything seems to be working.

This could be completely unrelated, but in the event that anyone else sees this; I installed miniconda after system python, but exported PATH from miniconda last, so in my case, my problems were caused by having two Python installations on the search path

I am seeing the same issue on a newly installed machine. Happy to provide more information if that would help.

@agoose77 Tyvm for the hint! :tada:

I had the same issue noted above where I was using miniconda3.

  • I fixed my issue by removing miniconda3 (rm -r ~/miniconda3).
  • Then I installed python3.6 (via a PPA on Ubuntu) which is the version my Pipfile specifies.
  • Then I specified that pipenv use python3.6 (pipenv --python $(which python3.6))
  • Then in my project directory, the one with the Pipfile I ran:

    • pipenv --rm to remove the existing environment

    • pipenv lock (the command I was trying to run successfully this whole time) to create an updated Pipfile.lock with the dependency I was trying to add

    • pipenv install to install dependencies and confirm that Pipfile.lock was correct

I was basically just lost in the world of Python versions, virtual environments, and dependency-management :sweat_smile:

Was this page helpful?
0 / 5 - 0 ratings