Search code examples
pythoncygwinwindows-8.1pip

win 8.1 cygwin - pip is installing into windows python directory?


I have recently just started the foray into running cygwin on windows.

Attempting to setup a development environment, and noticing some oddities. so for example, I have installed virtualenvwrapper but when i open a new cygwin terminal i get (after setting appropriate lines in my .bashrc)

-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory

so i attempt to reinstall virtualenvwrapper using pip and i get

$ pip install virtualenvwrapper
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in c:\python27\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): virtualenv in c:\python27\lib\site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in c:\python27\lib\site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): stevedore in c:\python27\lib\site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): argparse in c:\python27\lib\site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in c:\python27\lib\site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pbr!=0.7,<1.0,>=0.6 in c:\python27\lib\site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pip in c:\python27\lib\site-packages (from pbr!=0.7,<1.0,>=0.6->stevedore->virtualenvwrapper)

What gives? why is it installing it to the windows directory? sure enough i can see virtualenvwrapper is not installed in c:/cygwin64/lib/Python2.7/site-packages/ in fact that directory is completely bare. I expected to see the updated version of pip i installed. it's of course in the windows directory.

I had previously installed virtualenvwrapper via pip on windows, but my understanding is that the windows environment and the cygwin terminal are totally seperate and shouldn't know about each other(?)

as you might expect this is also wrecking havoc with other packages. for example attempting to install uwsgi i get this error:

Collecting uWSGI==2.0.7 (from -r _pip/requirements.txt (line 52))
  Downloading uwsgi-2.0.7.tar.gz (772kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "c:\cygwin64\tmp\pip-build-n5cvur\uWSGI\setup.py", line 3, in <module>
        import uwsgiconfig as uc
      File "uwsgiconfig.py", line 8, in <module>
        uwsgi_os = os.uname()[0]
    AttributeError: 'module' object has no attribute 'uname'

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in c:\cygwin64\tmp\pip-build-n5cvur\uWSGI

which i understand is because os.uname doesn't exist on windows. Why is the pip installer running setup using windows python?

------- update -------
I think i found the root cause

$ which pip
/c/Python27/Scripts/pip

so my questions are: why is pip the windows one by default? or how did this happen?

-------- Update 2 ----------
i just discovered that the default PATH env variable in cygwin appends the windows one. sure enough the path to the windows pip is there.

$ echo $PATH

Is this expected? if so, why is this desireable? doesn't it increase the chance of unintentional conflicts like this one?


Solution

  • So I'll just leave this here as a warning to n00bs like myself.

    cygwin appends the windows path to the cygwin terminal PATH env variable.

    if you already have pip installed on windows and it is on your path it will work but with unexpected results like above.

    to check make sure you do

    which python
    which pip
    

    to confirm what version you are running.

    only python 2.7.9 and up include pip by default and the package included in cygwin isn't there yet. so you will most likely need to install pip manually

    if you had a cygwin terminal open, you will need to close all windows otherwise it remembers the path to the windows pip.