在Windows 7上安装Cygwin后,Pip安装无法正常运行

20
我在刚安装在Windows 7电脑上的Cygwin中,无法让pip正常运行。希望有人能告诉我关于正确安装这些软件包方面我哪里做错了。首先,我按照以下网站上的说明进行操作:http://www.pip-installer.org/en/latest/installing.html,在pip安装之前安装了setuptools。我按照步骤进行,并运行了这个命令:
Ryan@Albert ~
$ python get-pip.py

我得到了这个输出:

Downloading/unpacking pip
Downloading pip-1.5.tar.gz (898kB): 898kB downloaded
  Running setup.py egg_info for package pip

    warning: no files found matching 'pip/cacert.pem'
    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.rst' found under direct
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Running setup.py install for pip

    warning: no files found matching 'pip/cacert.pem'
    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.rst' found under direct
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /usr/bin
    Installing pip2.7 script to /usr/bin
    Installing pip2 script to /usr/bin
Successfully installed pip
Cleaning up...

结果,出现了奇迹,只需使用以下命令运行pip:

Ryan@Albert ~
$ pip install --upgrade setuptools

这导致完全没有输出。在下方出现了一个空白行,持续3-4秒钟,然后输入提示符再次出现,而 pip 实际上并没有做任何事情。我进行了大量测试来确认我的机器上确实有一个名为pip的东西,但每次运行时,它基本上什么也没做。它没有下载或安装任何程序。

卸载第一个版本后,我试图以另一种方式安装pip。 这次我尝试了:

$ easy_install pip

并获得了以下输出:
Searching for pip
Best match: pip 1.5
Adding pip 1.5 to easy-install.pth file
Installing pip script to /usr/bin
Installing pip2.7 script to /usr/bin
Installing pip2 script to /usr/bin

Using /usr/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip

我再次尝试使用pip命令安装virtualenv:

$ pip install virtualenv

然后它暂停了3-4秒,之后又使命令提示符可用。这和之前完全一样。当我检查virtualenv是否已安装时,它没有被安装。

本质上,我已经尝试过很多次在我的Windows 7 Cygwin安装中运行pip,但都没有成功。我知道我可以使用其他软件包来安装插件等等,但如果有人知道为什么会出现这种情况,我会非常感激,这样在今后安装东西时就不会困扰我了。

非常感谢任何帮助!


1
出于好奇,考虑到你想要做的事情,为什么你要单纯地在Cygwin下进行?考虑到Cygwin只是“一个充当Linux API层提供大量Linux API功能”的动态链接库(cygwin1.dll),更好的做法是简单地安装适用于Windows的Python,并通过该方式安装pipvirtualenv。或者,在基于*nix的操作系统中安装Python到虚拟环境中。 - jrd1
嗯,我已经在Windows上安装了一个我喜欢的Python版本。当我尝试使用它时(例如导入numpy或其他东西),安装的功能无法正常工作。我认为这是因为我的路径文件链接到cygwin版本的python而不是之前安装的Windows版本。您建议我如何让Cygwin使用我的Windows安装?只需卸载cygwin python并修改路径文件以包括包含Windows Python安装的Windows文件夹即可吗? - rrphenix
您可以通过直接调用Windows安装程序来绕过Cygwin的安装。您是否尝试使用Windows的cmd提示符(按Win+R键,然后输入cmd并按Enter键),并像这样调用已安装在Windows上的Python和pip(例如:C:\Python27\Scripts\pip.exe install virtualenv)? - jrd1
1
啊,太好了!你救了我一命。最终我采用了你建议的直接使用Windows文件路径(例如$/cygdrive/c/Users/Ryan/Anaconda/Scripts/pip.exe install virtualenv),避开Cygwin的安装,直接在Windows上安装包。采用这种策略,我只用了几秒钟就安装好了所有东西。再次感谢! - rrphenix
3个回答

24
在64位Cygwin中存在一个错误(?),导致ctypes.util在尝试查找libuuid (/usr/bin/cyguuid-1.dll)时崩溃。解决方法是从Cygwin安装程序中安装libuuid-devel。我是从对requests.py提出的问题中发现这个问题的,但其他一些地方也注意到了这个问题,并以不同的方式进行了处理。

3
你真是个及时雨! - CMCDragonkai
这也解决了我的问题。谢谢!但是我之前已经安装了binutils,所以我不知道它是否也是必需的。 - David Ferenczy Rogožan
@DawidFerenczy:我不确定...我也已经安装了binutils :-) 另外:谢谢!你让我超过了1000个声望! - Tripp Lilley
1
我不知道为什么,但是安装这些软件包并不能解决我的问题。我会坐等30分钟以上;到那时,我就认为程序已经无限期地挂起了。有趣的是,将-vvv添加到参数中会显示它在新的HTTPS阶段挂起。 - PikalaxALT

4

我也遇到了同样的问题。安装 binutils cygwin 包解决了我的问题。


我不知道为什么之前的回答被踩得这么厉害。我来这里是想弄清楚为什么在Cygwin64上执行pip install -r REQUIREMENTS.txt时什么都没发生(甚至没有错误消息)。我安装了binutils包,神奇地它开始工作了。 - cardonator

0

针对这个问题,有一个解决方法:您可以将输出重定向到另一个进程或文件。

例如:

pip | more

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  help                        Show help for commands.

这将允许查看标准输出,但不包括标准错误。为了查看标准错误,它也应该被重定向:

pip 2>&1 | more

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接