54

While I am aware of the option of installing Pip from source, I'm trying to avoid going down that path so that updates to Pip will be managed by Cygwin's package management.

I've recently learned that the latest versions of Python include Pip. However, even though I have recently installed the latest versions of Python from the Cygwin repos, Bash doesn't recognize a valid Pip install on the system.

896/4086 MB RAM 0.00 0.00 0.00 1/12 Tue, Jun 16, 2015 ( 3:53:22am CDT) [0 jobs]
[ethan@firetail: +2] ~ $ python -V
Python 2.7.10
892/4086 MB RAM 0.00 0.00 0.00 1/12 Tue, Jun 16, 2015 ( 3:53:27am CDT) [0 jobs]
[ethan@firetail: +2] ~ $ python3 -V
Python 3.4.3
883/4086 MB RAM 0.00 0.00 0.00 1/12 Tue, Jun 16, 2015 ( 3:53:34am CDT) [0 jobs]
[ethan@firetail: +2] ~ $ pip
bash: pip: command not found
878/4086 MB RAM 0.00 0.00 0.00 1/12 Tue, Jun 16, 2015 ( 3:53:41am CDT) [0 jobs]
[ethan@firetail: +2] ~ $ pip2
bash: pip2: command not found
876/4086 MB RAM 0.00 0.00 0.00 1/12 Tue, Jun 16, 2015 ( 3:53:42am CDT) [0 jobs]
[ethan@firetail: +2] ~ $ pip3
bash: pip3: command not found

Note that the installed Python 2.7.10 and Python 3.4.3 are both recent enough that they should include Pip.

Is there something that I might have overlooked? Could there be a new install of Pip that isn't in the standard binary directories referenced in the $PATH? If the Cygwin packages of Python do in fact lack an inclusion of Pip, is that something that's notable enough to warrant a bug report to the Cygwin project?

Community
  • 1
  • 1
redyoshi49q
  • 681
  • 1
  • 5
  • 7
  • 2
    Interesting shell prompt. – rr- Jun 16 '15 at 11:13
  • 21
    You can try `python -m pip` to see if pip is actually installed in your interpreter. In the latest versions `python -m ensurepip` should bootstrap pip, if it's not already present. On pip's website you can also find `get-pip.py` to bootstrap pip. – cel Jun 16 '15 at 16:04
  • @rr- I'm a customization junkie. My prompt's a modification of one that I found online. I can't easily find the original source, but [this](http://www.thegeekstuff.com/2008/09/bash-shell-ps1-10-examples-to-make-your-linux-prompt-like-angelina-jolie/) is an example of the basics. I use both $PROMPT_COMMAND and $PS1; on a non-Cygwin system, it would make sense to implement the first line as $PROMPT_COMMAND and the second as $PS1 (so that pressing enter on a blank line looks right), but on Cygwin, I put some of the first line in $PS1 to reduce forks for performance reasons. – redyoshi49q Jun 16 '15 at 22:24
  • 2
    @cel `python -m pip` produced `/usr/bin/python: No module named pip`, but running `python -m ensurepip` seems to have installed pip, as verified by running `pip` in bash. Having said that, I don't know whether future updates to Python through Cygwin will also update Pip; that was my original goal in posting this question. – redyoshi49q Jun 16 '15 at 22:28

2 Answers2

105

cel self-answered this question in a comment above. For posterity, let's convert this helpfully working solution into a genuine answer.

Unfortunately, Cygwin currently fails to:

  • Provide pip, pip2, or pip3 packages.
  • Install the pip and pip2 commands when the python package is installed.
  • Install the pip3 command when the python3 package is installed.

It's time to roll up our grubby command-line sleeves and get it done ourselves.

What's the Catch?

Since no pip packages are currently available, the answer to the specific question of "Is pip installable as a Cygwin package?" is technically "Sorry, son."

That said, pip is trivially installable via a one-liner. This requires manually re-running said one-liner to update pip but has the distinct advantage of actually working. (Which is more than we usually get in Cygwin Land.)

pip3 Installation, Please

To install pip3, the Python 3-specific version of pip, under Cygwin:

$ python3 -m ensurepip

This assumes the python3 Cygwin package to have been installed, of course.

pip2 Installation, Please

To install both pip and pip2, the Python 2-specific versions of pip, under Cygwin:

$ python -m ensurepip

This assumes the python Cygwin package to have been installed, of course.

Cecil Curry
  • 7,816
  • 4
  • 30
  • 40
  • @cel is actually the one to credit as the source for the answer; he was the first to propose that solution. – redyoshi49q Aug 13 '15 at 17:55
  • Oh! Quite right. You're awesome too, of course. (_This has been fixed._) – Cecil Curry Apr 21 '16 at 05:38
  • 1
    After installing, to upgrade `pip` to the latest version, run `python3 -m pip install --upgrade pip` – zelanix Jun 23 '16 at 07:37
  • upgrading pip2 causes pip3 to vanish. and `python3 -m ensurepip` does not work again. – Lord Loh. Sep 24 '16 at 22:06
  • 1
    I got back access to my `pip3` by `python3 -m pip install --upgrade pip` – Lord Loh. Sep 25 '16 at 04:51
  • The steps first would be even better. If I have to read through all the explanations, chances are high I boil out. Simple solution steps first and then the explanation would be better (also for your points ;-) – trapicki Feb 17 '17 at 07:47
  • I deleted the `python` and `pip` file link associations in `\usr\bin` so that I now have to explicitly request a python/pip version (thus avoiding the "which python is this" conundrum). – yeliabsalohcin Jul 23 '18 at 13:36
  • Added a supporting video here in actual action in my cygwin: https://asciinema.org/a/hSu4kmJ6wb7b2UiuvxiXqtgGK – eigenfield Oct 11 '18 at 19:40
8
  1. Download a helper package:

  2. Run the script:

    • For Python 2.7 run: easy_install-2.7 pip
    • For Python 3.4 run: easy_install-3.4 pip
StackzOfZtuff
  • 1,671
  • 18
  • 19
moovon
  • 1,875
  • 1
  • 13
  • 12
  • This doesn't seem to allow Cygwin's package manager to keep Pip updated (which was my initial goal). It's also more complicated than cel's comment (which was codified into an answer by Cecil) due to requiring another package and specifying an exact version number. It may be useful to legacy Python users, though. – redyoshi49q Sep 24 '15 at 03:31
  • 2
    Thanks, for some reason my install of pip was broken, and `python -m ensurepip` wasn't able to resurrect. But `easy_install-2.7 --upgrade pip` worked like a charm. – Jade Dec 16 '15 at 19:57