在命令行上为 IronPython 安装 pip

Posted

技术标签:

【中文标题】在命令行上为 IronPython 安装 pip【英文标题】:Install pip for IronPython on commandline 【发布时间】:2014-12-31 07:46:04 【问题描述】:

是否可以通过命令行在 IronPython 中安装和使用 pip? (我不是通过 PTVS 这样做的。)

我已经尝试过的事情:

看了这个 SO 问题:Installing Python Packages - IronPython,但已经一年多没有回答或更新了。

查看了这个答案on Yahoo,但指向distribute_setup.py 的链接已损坏。我从这里得到了一份副本:distribute_setup.py,它以这个结尾:

IOError: System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

查看了pip docs,但这显然是针对 CPython,而不是 IronPython。

按照Steps to installing setuptools on IronPython 上的步骤进行操作。根据cmets,它在去年8月工作,但我得到了和上面一样的错误:

IOError: System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

查看这些错误的完整输出。它似乎捡起了鸡蛋,但在调用urllib2.urlopen(url)的过程中后来失败了:

Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
  File "ez_setup.py", line 158, in download_setuptools
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 126, in urlopen
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 400, in open
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 512, in http_response
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 432, in error
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 372, in _call_chain
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 619, in http_error_302
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 394, in open
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 411, in _open
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 372, in _call_chain
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 1168, in do_open
  File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 955, in request
  File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 951, in endheaders
  File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 811, in _send_output
  File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 1158, in connect
  File "C:\Program Files (x86)\IronPython 2.7\Lib\ssl.py", line 366, in wrap_socket
  File "C:\Program Files (x86)\IronPython 2.7\Lib\ssl.py", line 133, in __init__
  File "C:\Program Files (x86)\IronPython 2.7\Lib\ssl.py", line 295, in do_handshake
  File "ez_setup.py", line 278, in <module>
  File "ez_setup.py", line 210, in main
  File "C:\Program Files (x86)\IronPython 2.7\Lib\urllib2.py", line 1207, in https_open
  File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 989, in _send_request
  File "C:\Program Files (x86)\IronPython 2.7\Lib\httplib.py", line 773, in send
IOError: System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

还有什么想法可以尝试,或者这是否可能有效?

【问题讨论】:

请查看***.com/questions/26663366/… 谢谢@PawelJasinski!我试过了,但不是 IronPython 2.7.5b3。我想这个问题应该被标记为重复,但我认为我没有代表这样做。 【参考方案1】:

我在硬盘驱动器上安装了常规 (CPython),并将 IronPython 引擎 setsearchpaths Importing external module in IronPython 设置到其 Lib 和 Lib\site-packages 目录。然后我可以将包安装到 CPython 中并在我的 IronPython 脚本中使用它们。不过,这可能不适用于每个包。

【讨论】:

以上是关于在命令行上为 IronPython 安装 pip的主要内容,如果未能解决你的问题,请参考以下文章

在 Debian 9/10 上为 python 3.8 安装 mod_wsgi

如何从左表返回行,其中右表的条件在没有子查询的所有行上为真

如何在命令行上安装 Android SDK Build Tools?

Windows命令行上的Node.js npm错误

如何在IronPython控制台中清除屏幕?

如何在 Ubuntu 网络服务器上为 Dart 安装 pub(命令行使用)