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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in 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
Python 3
In case you dont have pip installed install it using below command
or
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...
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:
You must replace
a.b
with your python version which can be 2.7 or 3.4 or whatever else.I think the alternative install instructions linked by mata are simplest:
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.
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.
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
.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.
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: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: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.