hidemyname
hidemyname

Reputation: 4287

How to let the python in cygwin use the package installed in windows?

I installed python on both cygwin and windows. However, there is no package installed in cygwin's site-packages. Here the directory is /usr/lib/python2.7/site-packages. In contrast, they are all installed in C:\Python\Lib\site-packages. Since I installed the packages in C:\Python\Lib\site-packages, pip in cygwin will skip the installation of those packages. Is there a method I directly use the packages in windows?

Upvotes: 0

Views: 2917

Answers (1)

Doug Henderson
Doug Henderson

Reputation: 898

First, make sure (in cygwin bash) that python2 and/or python3 is/are ahead of the windows versions of the programs in your path. As of this writing, python 2, if installed, can be called aspython or python2, while python 3 is called python3. This may change as more Linux distributions switch to using python 3 as the default. Use python -V or python3 -V to verify that you get the cygwin version of python when running bash. (I no long install python 2.)

$ which python
which: no python in (**"your path"**)
$ which python3
/usr/bin/python3
$ python3 -V
Python 3.6.4

Then verify that you can run the appropriate version of pip for your python. To be absolutely sure of which version you are using, run

$ python3 -m pip --version
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

Now you should be able to install most packages from PiPI by replacing pip or pip3 with python -m pip or python3 -m pip.

If you try to install a package that requires compilation, i.e, one that is distributed as a binary package on windows, you will need to have the gcc compiler tool chain, and possibly the python-devel or python3-devel package. BTW, always use the latest cygwin setup program from cygwin.com. You may also need to install any required cygwin packages using setup before the package will install.

HTH

Doug

Upvotes: 1

Related Questions