Nixpkgs: Recent versions of nixpkgs evidence problems with pip (Python)

Created on 4 Nov 2019  路  3Comments  路  Source: NixOS/nixpkgs

Describe the bug
The below nix-shell expression, when run, fails with this error:

$ nix-shell shell.nix
Using base prefix '/nix/store/80qva2zal82njkg4zvb7xg94mnikqksd-python3-3.6.8'
New python executable in /home/nixos/CIDA/cow_health/venv/bin/python3.6m
Also creating executable in /home/nixos/CIDA/cow_health/venv/bin/python
Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/home/nixos/CIDA/cow_health/venv/bin/pip", line 7, in <module>
    from pip._internal.main import main
ModuleNotFoundError: No module named 'pip._internal.main'
Traceback (most recent call last):
  File "/home/nixos/CIDA/cow_health/venv/bin/pip", line 7, in <module>
    from pip._internal.main import main
ModuleNotFoundError: No module named 'pip._internal.main'

Here is the nix expression:

with import <nixpkgs> {};
with pkgs.python36Packages;
stdenv.mkDerivation {
  name = "impurePythonEnv";
  buildInputs = [
    # these packages are required for virtualenv and pip to work:
    #
    mypy
    python36Full
    python36Packages.virtualenv
    python36Packages.pip

    python36Packages.numpy
  ];
  src = null;
  # TODO: convert to full nix expression so as to not rely on pip
  shellHook = ''
    # set SOURCE_DATE_EPOCH so that we can use python wheels
    SOURCE_DATE_EPOCH=$(date +%s)
    export LANG=en_US.UTF-8
    virtualenv venv
    source venv/bin/activate
    export PATH=$PWD/venv/bin:$PATH
    export PYTHONPATH=$PWD:$PYTHONPATH
    pip install mypy Cython
    pip install pandas rope sxapi
    source $HOME/.dairy_creds.sh
  '';
}

To Reproduce
Steps to reproduce the behavior:

  1. Create the above nix expression in a file (shell.nix)
  2. nix-shell shell.nix

Expected behavior
In the recent past, before updating my system, this succeeded.

Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.

  • system: "x86_64-linux"
  • host os: Linux 4.14.118, NixOS, 18.09.2574.a7e559a5504 (Jellyfish)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.1.3
  • channels(nixos): ""
  • channels(root): "nixos-18.09.2574.a7e559a5504"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
bug python

All 3 comments

Also, i noticed you're using 18.09, you may want to bump to a more recent nixos version

Thanks, I updated (finally) and followed the advice in that issue, in particular https://github.com/NixOS/nixpkgs/issues/71178#issuecomment-562609408, and everything is peachy.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ayyess picture ayyess  路  3Comments

domenkozar picture domenkozar  路  3Comments

retrry picture retrry  路  3Comments

matthiasbeyer picture matthiasbeyer  路  3Comments

grahamc picture grahamc  路  3Comments