日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python pip全称_“ pip install”和“ pip install”之间有什么区别和“ python -m pip install”?...

發(fā)布時間:2023/12/19 python 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python pip全称_“ pip install”和“ pip install”之间有什么区别和“ python -m pip install”?... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

I have a local version of Python 3.4.1 and I can run python -m pip install, but I'm unable to find the pip binary to run pip install. What's the difference between these two?

解決方案

2014

They do exactly the same thing. In fact, the docs for distributing Python modules were just updated to suggest using python -m pip instead of the pip executable, because it's easier to tell which version of python is going to be used to actually run pip that way.

Here's some more concrete "proof", beyond just trusting my word and the bug report I linked :)

If you take a look at the pip executable script, it's just doing this:

from pkg_resources import load_entry_point

load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()

It's calling load_entry_point, which returns a function, and then executing that function. The entry point it's using is called 'console_scripts'. If you look at the entry_points.txt file for pip (/usr/lib/python2.7/dist-packages/pip-1.5.4.egg-info/entry_points.txt on my Ubuntu machine), you'll see this:

[console_scripts]

pip = pip:main

pip2.7 = pip:main

pip2 = pip:main

So the entry point returned is the main function in the pip module.

When you run python -m pip, you're executing the __main__.py script inside the pip package. That looks like this:

import sys

from .runner import run

if __name__ == '__main__':

exit = run()

if exit:

sys.exit(exit)

And the runner.run function looks like this:

def run():

base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

## FIXME: this is kind of crude; if we could create a fake pip

## module, then exec into it and update pip.__path__ properly, we

## wouldn't have to update sys.path:

sys.path.insert(0, base)

import pip

return pip.main()

As you can see, it's just calling the pip.main function, too. So both commands end up calling the same main function in pip/__init__.py.

總結(jié)

以上是生活随笔為你收集整理的python pip全称_“ pip install”和“ pip install”之间有什么区别和“ python -m pip install”?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。