Pipenv: pip 18.1: pipenv graph results in ImportError: cannot import name 'get_installed_distributions'

Created on 5 Oct 2018  路  10Comments  路  Source: pypa/pipenv

Issue description

When you install pip 18.1 (not reproducible with pip 18.0 and below), pipenv graph fails with ImportError.

Expected result

I expect pipenv graph to work with no exceptions.

Actual result
$ pipenv graph
Traceback (most recent call last):
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/pipdeptree.py", line 17, in <module>
    from pip._internal import get_installed_distributions
ImportError: cannot import name 'get_installed_distributions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".../.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File ".../.local/lib/python3.6/site-packages/pipenv/cli.py", line 922, in graph
    do_graph(bare=bare, json=json, json_tree=json_tree, reverse=reverse)
  File ".../.local/lib/python3.6/site-packages/pipenv/core.py", line 2363, in do_graph
    import pipdeptree
  File ".../.local/lib/python3.6/site-packages/pipenv/vendor/pipdeptree.py", line 20, in <module>
    from pip import get_installed_distributions, FrozenRequirement
ImportError: cannot import name 'get_installed_distributions'

Most helpful comment

This is caused py pipenv not being compatible to the latest release of pip.

2924 is another error cause by the same issue.

The workaround that works there is valid for this issue downgrade your pip to a version prior to 18.1.

I'm currently using

python3 -m pip install pip==10.0.1
python3 -m pip install pipenv==2018.5.18

Once #2924 is fixed and released, you can upgrade again to the latest and greatest.

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pipenv

All 10 comments

This is caused py pipenv not being compatible to the latest release of pip.

2924 is another error cause by the same issue.

The workaround that works there is valid for this issue downgrade your pip to a version prior to 18.1.

I'm currently using

python3 -m pip install pip==10.0.1
python3 -m pip install pipenv==2018.5.18

Once #2924 is fixed and released, you can upgrade again to the latest and greatest.

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pipenv

Depending on whether this is fixed upstream we can either patch this or upgrade

I was looking into how pip is used in Pipenv, and this one is actually different from #2924. We鈥檝e migrated to pip-shims in most code paths, but pipenv graph uses an (rather obscure) code path that imports pip directly. We鈥檒l need to patch pipdeptree to fix this.

Ah, excellent!

fixed in master as well, thanks for the quick turn around @naiquevin

also released

I upgraded pipenv and currently have the following versions:

$ python --version
Python 2.7.12
$ pipenv --version
pipenv, version 2018.10.9
$ pip --version
pip 18.1 from /home/coolcude/.local/lib/python2.7/site-packages/pip (python 2.7)

Since it was released I assume it would have been fixed in 2018.10.9? I still get:

$ pipenv graph

ERROR:  Traceback (most recent call last):
  File "/home/cooldude/.local/lib/python2.7/site-packages/pipenv/vendor/pipdeptree.py", line 16, in <module>
    from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement
ImportError: No module named pipenv.vendor.pip_shims

I'm getting a similar issue to @thernstig above. Just updated this morning.

$ python --version
Python 3.6.5
$ pipenv --version
pipenv, version 2018.10.9
$ pip --version
pip 18.1 from /usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pip (python 3.7)

Error below:

$ pipenv graph

ERROR:  Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pipdeptree.py", line 16, in <module>
    from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement
ModuleNotFoundError: No module named 'pipenv'

@thernstig @joshnewlinatclearobject See #2952.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bgjelstrup picture bgjelstrup  路  3Comments

jacebrowning picture jacebrowning  路  3Comments

ipmb picture ipmb  路  3Comments

Californian picture Californian  路  3Comments

jacek-jablonski picture jacek-jablonski  路  3Comments