Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirakaba/3ba986ecd04d1a7e603bdf18d90d5dae to your computer and use it in GitHub Desktop.
Save shirakaba/3ba986ecd04d1a7e603bdf18d90d5dae to your computer and use it in GitHub Desktop.
How to install pip and six on macOS with Nix and home-manager

Given the following Nix packages (you may be able to install six manually rather than managing it by Nix, but anyway, this was my setup):

pkgs.python310Full
pkgs.python310Packages.six

I would very often run into this situation:

/usr/local/bin/pip: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

This is because a certain version of pip is hard-coded with a shebang to use the macOS python rather than just the one on your path (your Nix one).

I found the only way forwards was to edit it:

# Find where pip is installed
$ which pip
/usr/local/bin/pip

# Edit it
$ sudo nano /usr/local/bin/pip

I edited it to hard-code the version number of my own installation of pip, and made it use the python on my path, which is Python v3.10.

#!/Users/jamie/.nix-profile/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==22.3.1','console_scripts','pip'
__requires__ = 'pip==22.3.1'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('pip==22.3.1', 'console_scripts', 'pip')()
    )

From there, I tried pip install --upgrade pip as many comments on StackOverflow recommended, but it seemed to no-op.

After that, just:

pip install six

... and then nativescript doctor was happy.

I'd better remove the redundant pkgs.python310Packages.six now, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment