如何从 GitHub 安装 Python 包?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15268953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 19:39:12  来源:igfitidea点击:

How to install Python package from GitHub?

pythonpip

提问by Colonel Panic

I want to use a new feature of httpie. This feature is in the github repo https://github.com/jkbr/httpiebut not in the release on the python package index https://pypi.python.org/pypi/httpie

我想使用 httpie 的一个新功能。此功能在 github 存储库https://github.com/jkbr/httpie 中,但不在 python 包索引https://pypi.python.org/pypi/httpie上的发布中

How can I install the httpie package from the github repo? I tried

如何从 github 存储库安装 httpie 包?我试过

pip install https://github.com/jkbr/httpie

But I got an error 'could not unpack'

但我收到一个错误“无法解包”



In Nodejs, I can install packages from github like this

在 Nodejs 中,我可以像这样从 github 安装包

npm install git+https://github.com/substack/node-optimist.git

采纳答案by Martijn Pieters

You need to use the proper git URL:

您需要使用正确的 git URL:

pip install git+https://github.com/jkbr/httpie.git#egg=httpie

Also see the VCS Supportsectionof the pip documentation.

另请参阅pip 文档的VCS 支持部分

Don't forget to include the egg=<projectname>part to explicitly name the project; this way pip can track metadata for it without having to have run the setup.py script.

不要忘记包含明确命名项目egg=<projectname>部分;这样 pip 就可以跟踪它的元数据,而无需运行 setup.py 脚本。

回答by Sagar Rakshe

To install Python package from github, you need to clone that repository.

要从 github 安装 Python 包,您需要克隆该存储库。

git clone https://github.com/jkbr/httpie.git

Then just run the setup.py file from that directory,

然后只需从该目录运行 setup.py 文件,

sudo python setup.py install