Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vlasovskikh opened this issue Oct 5, 2018 · 10 comments

Comments

@vlasovskikh
Copy link

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'
@florisla
Copy link

florisla commented Oct 5, 2018

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

@techalchemy
Copy link
Member

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

@uranusjr
Copy link
Member

uranusjr commented Oct 5, 2018

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

@naiquevin
Copy link

It's been fixed in pipdeptree version 0.13.1.

tox-dev/pipdeptree@ba67474

@uranusjr
Copy link
Member

uranusjr commented Oct 8, 2018

Ah, excellent!

@techalchemy
Copy link
Member

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

@techalchemy
Copy link
Member

also released

@thernstig
Copy link

thernstig commented Oct 9, 2018

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

@joshnewlinatclearobject
Copy link

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'

@vlasovskikh
Copy link
Author

@thernstig @joshnewlinatclearobject See #2952.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants