python无pip exe文件,为什么IronPython告诉我pip是一个包而不是可执行文件?

I am a complete newbie at Python. I wanted to try to see if Pyomo (a Python package for mathematical modeling) could work under IronPython because all my code for generating the data needed for Pyomo is in C#.

I installed IronPython 2.7.5, then tried as an administrator the advice found in http://blog.ironpython.net/2014/12/pip-in-ironpython-275.html#disqus_thread on how to run "pip" for IronPython. I used the exact example they gave (installing html5lib):

ipy -X:Frames -m ensure pip

ipy -X:Frames -m pip install html5lib

The first line worked, and I see in the Lib/site-packages directory a folder called pip-6.1.1-py2.7.egg with lots of python code in it.

For the second line, I received the error:

Unhandled exception:

Traceback (most recent call last):

File "C:\Program Files (x86)\IronPython 2.7\Lib\runpy.py", line 170, in run_module

File "C:\Program Files (x86)\IronPython 2.7\Lib\runpy.py", line 111, in _get_module_details

ImportError: No module named urllib; 'pip' is a package and cannot be directly executed

At this point, I'm stuck. Any help would be appreciated.

Just in case this helps, printing out the sys.version gives:

2.7.5 (IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.34209 (32-bit))

解决方案

I encountered the same problem. It seems that IronPython can't deal with more recent versions of pip. What I did was:

remove all traces from pip and setuptools from IronPython's Lib\site-packages folder

run from a commandline: ipy.exe -X:Frames -m ensurepip

this installed an old version of pip, one that IronPython understands. Verify this by checking that a folder pip-1.5.6.dist-info appears in IronPython's Lib/site-packages

Moral of the story; don't upgrade to a newer pip version when using IronPython

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值