Some Python packages need external dependencies in order to be able to call their in order to gather information about the package. This problem is commonly faced when using pip2nix to freeze the Python dependencies into a Nix expression as in the following issue:

A quick way to make the dependencies available is using nix-shell with the flag -p. This leads to an inconvenient problem though. The prompt looks like the following example:


The background of this problem has been analyzed in the following pull request:

I found two options which can be applied as a workaround to this problem. The first option is to use switch --command to run the command directly via nix-shell, this does not fix anything, but it hides the problem:

nix-shell -p python27Packages.cffi \
       --command 'pip2nix generate -r requirements.txt -c constraints.txt'

The other option is to sneak a different bash by tweaking the environment variable PATH and then running the command manually inside of the second shell. The path from this example is what I did use on my mac:

PATH=/bin:$PATH nix-shell -p python27Packages.cffi


comments powered by Disqus