Installing Pip-3.2 on Cygwin
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?
Solution 1:
1)While installing cygwin, make sure you install the python/python-setuptools from the list. This will install "easy_install" package.
2) 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:
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:
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:
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.