Installing Pip-3.2 on Cygwin

PythonPython 3.xCygwinPip

Python Problem Overview


I have Python 3 installed on Cygwin. However, I am unable to install Python 3 packages via pip. Is there a way to do this?

Python Solutions


Solution 1 - Python

1)While installing cygwin, make sure you install the python/python-setuptools from the list. This will install "easy_install" package.

  1. Type the following command:

    easy_install-a.b pip

You must replace a.b with your python version which can be 2.7 or 3.4 or whatever else.

Solution 2 - Python

If you have more than one python installation, then you need to install pip (and probably also setuptools) for each installation separately.
To do so, you can first download ez_setup.py and run it with python3:

/usr/bin/python3 ez_setup.py

That should install setuptools, and also create an easy_install script for your python version, e.g. /usr/bin/easy_install-3.2, which you can use to install pip:

/usr/bin/easy_install-3.2 pip

This will install pip into your python3 site packages directory, and again create a script /usr/bin/pip-3.2, which you can use to install packages for this python version.

Alternatively you can follow the install instructions from here and here.

Solution 3 - Python

I think the alternative install instructions linked by mata are simplest:

> To install pip, securely download get-pip.py. > > Then run the following (which may require administrator access): > > python get-pip.py

Solution 4 - Python

Since OP specifically talks about Python3, I think we need to specify that just in case the user already have Python2 installed, which is very likely.

# If you don't have Python3 already, use apt-cyg:
apt-cyg install python3
 
# First update pip, pip2 
pip2 install --upgrade pip 

# Install pip3:
python3 -m ensurepip

# Finally update pip3:
pip3 install --upgrade pip

$ pip3 -V
pip 9.0.1 from /usr/lib/python3.4/site-packages (python 3.4)

BTW. There are several forks of apt-cyg, but the best maintained is that of kou1okada, you'll love it.


EDIT: 2018-11-15

Because I started out not using virtualenv, I recently had to refresh my Cygwin Python3 installation, and realized a few things in the process that should have been obvious, but can easily be forgotten.

  • When installing and using Python3 on Cygwin (and probably on most other *nix distros), only install the basic Python3 interpreter as a Cygwin package. From then on, only use the pip installer.

  • After you have installed or updated any python3 packages using pip, your Cygwin package manager will complain that your package is "Incomplete". That is because pip has replaced/updated the files in that package. Check with: cygcheck.exe -c |grep Incomplete.
    Do not re-install those packages with Cygwin.

# cygcheck.exe -c |grep Incomplete
python3-setuptools      34.3.2-1         Incomplete

So what I did, was clear out all python3 related Cygwin packages, except the Python3 itself. Then I re-installed the only one needed: python3-setuptools.

# apt-cyg remove python3-setuptools
apt-cyg install python3-setuptools

# Fix pip3 symlink (or just pip if you don't have python2)
ln -s /usr/bin/pip3.6 /usr/bin/pip3

# That also installs the Cygwin packages:  
# python3-appdirs, python3-packaging, python3-pyparsing, python3-six

# Now, update setuptools with pip:
pip3 install -U --force-reinstall --only-binary=:all: --no-clean --no-cache-dir setuptools

# pip list |grep setuptools
setuptools          40.5.0

That should have also have re-installed all the setuptools dependencies with the latest updates.

From now on, do yourself a favor and start using a virtual environment.

Solution 5 - Python

On windows, you can use pip to install packages. If you have multiple python installations under cygwin, give the full python path e.g. Python 2

/usr/bin/python2.7 -m pip install pyyaml

Python 3

/usr/bin/python3.6 -m pip install pyyaml

In case you dont have pip installed install it using below command

/usr/bin/python2.7 -m ensurepip 

or

/usr/bin/python3.6 -m ensurepip

Solution 6 - Python

I just learned, inspired from https://www.scivision.co/install-pip-in-cygwin/ and the answer before, that instead of using pip, you just have to use pip2 for python2 or pip3 for python 3 in cygwin on windows. Wondered about this the whole day...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDavid Y. StephensonView Question on Stackoverflow
Solution 1 - PythonmoovonView Answer on Stackoverflow
Solution 2 - PythonmataView Answer on Stackoverflow
Solution 3 - PythonsvickView Answer on Stackoverflow
Solution 4 - Pythonnot2qubitView Answer on Stackoverflow
Solution 5 - PythonNitin_k29View Answer on Stackoverflow
Solution 6 - PythonDanielWView Answer on Stackoverflow