1

I am new to using pipenv virtual environments. I am using one with a Django project. Recently I tried to start the environment with pipenv shell. I got a message that something like there was no environment available even though I have been using it for several months.

I exited the directory and re-entered. Then ran pipenv shell again. This time the env was activated. However when I try to install a package or run pipenv lock --clear I get the following error:

Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 
Traceback (most recent call last):
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 758, in main
    _main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/resolver.py", line 695, in resolve_packages
    from pipenv.core import project
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/core.py", line 33, in <module>
    from .project import Project
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/project.py", line 30, in <module>
    from .vendor.requirementslib.models.utils import get_default_pyproject_backend
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/requirementslib/__init__.py", line 9, in <module>
    from .models.lockfile import Lockfile
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/requirementslib/models/lockfile.py", line 14, in <module>
    from ..utils import is_editable, is_vcs, merge_items
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/requirementslib/utils.py", line 8, in <module>
    import pip_shims.shims
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/__init__.py", line 26, in <module>
    from . import shims
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/shims.py", line 12, in <module>
    from .models import (
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 790, in <module>
    Command.add_mixin(SessionCommandMixin)
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 704, in add_mixin
    mixin = mixin.shim()
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 752, in shim
    result = self.traverse(top_path)
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 744, in traverse
    result = shim.shim()
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 590, in shim
    imported = self._import()
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 615, in _import
    result = self._import_module(self.calculated_module_path)
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/vendor/pip_shims/models.py", line 365, in _import_module
    imported = importlib.import_module(module)
  File "/Users/mainuser/.pyenv/versions/3.9.2/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/cli/req_command.py", line 15, in <module>
    from pipenv.patched.notpip._internal.index.package_finder import PackageFinder
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index/package_finder.py", line 21, in <module>
    from pipenv.patched.notpip._internal.index.collector import parse_links
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index/collector.py", line 12, in <module>
    from pipenv.patched.notpip._vendor import html5lib, requests
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/requests/__init__.py", line 97, in <module>
    from pipenv.patched.notpip._vendor.urllib3.contrib import pyopenssl
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/Users/mainuser/anaconda/lib/python3.6/site-packages/OpenSSL/rand.py", line 213, in <module>
    _lib.ERR_load_RAND_strings()
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'

I am not sure how to interpret this but it looks like python3.6 is being used when the shell and project python version is 3.9.

Any ideas about what is causing this and how to fix it?

Finn
  • 163
  • 6
  • I think the problem is that I accidentally ran a sudo command while inside the pipenv. I tried closing the terminal and reentering the shell, but this has not solved the problem. Any suggestions? – Finn Nov 05 '21 at 22:25
  • This is answered in https://stackoverflow.com/questions/43267157/python-attributeerror-module-object-has-no-attribute-ssl-st-init/43267158 namely `pip uninstall pyopenssl` and `pip install pyopenssl` fixes it (without getting the same error from `pip upgrade` or `easy_install`) – Matteo Ferla Jan 10 '22 at 11:40

0 Answers0