Skip to content

in nix-shell, 'pipenv install' etc. fail with "ModuleNotFoundError: No module named 'pip._internal'" #39558

@das-g

Description

@das-g

Issue description

pipenv commands that use pip internally or explicitly fail.

Steps to reproduce

  1. make sure we're in a pristine and safely disposable directory
    cd $(mktemp -d)
  2. run a pipenv command that uses pip explicitly
    nix-shell -p pipenv --run 'pipenv run pip --version'

Expected

  • Virtualenv is created
  • Pipfile is created
  • Version of pip in that virtualenv is displayed

Observed

  • ✔️ Virtualenv is created
     Creating a virtualenv for this project…
     ⠋Using base prefix '/nix/store/ljhgdba6n8ag6f8clpi4m9zizm7b8mx3-python3-3.6.5'
     New python executable in /home/das-g/.local/share/virtualenvs/tmp.btSs5gvz0u-HGofKOag/bin/python3.6m
     Also creating executable in /home/das-g/.local/share/virtualenvs/tmp.btSs5gvz0u-HGofKOag/bin/python
     Installing setuptools, pip, wheel...done.
     Virtualenv location: /home/das-g/.local/share/virtualenvs/tmp.btSs5gvz0u-HGofKOag
    
  • ✔️ Pipfile is created
    Creating a Pipfile for this project…
    
  • ✖️ Then, a ModuleNotFoundError error is displayed:
    Traceback (most recent call last):
      File "/home/das-g/.local/share/virtualenvs/tmp.btSs5gvz0u-HGofKOag/bin/pip", line 7, in <module>
        from pip._internal import main
    ModuleNotFoundError: No module named 'pip._internal'
    

Cleanup after reproducing

In this order:

  1. Remove the virtualenv:
    nix-shell -p pipenv --run 'pipenv --rm'
  2. cd - and remove the temporary directory with its content

Variations

Similar observations for

  • pipenv commands using pip internally, e.g. pipenv install requests
  • invoking pip in a pipenv shell:
    nix-shell -p pipenv --run 'pipenv shell'
    pip --version
  • doing any of the above in an interactive nix-shell with pipenv

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.35, NixOS, 18.03.132083.06c576b0525 (Impala)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0
  • channels(root): "nixos-18.03.132083.06c576b0525"
  • channels(das-g): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions