简体   繁体   English

如何在没有pip的python项目中包含来自github的库?

[英]How do I include library from github in python project without pip?

I'm not sure what's the python way to include another library getting from github. 我不确定从github包含另一个库的python方法是什么。

I'm planning to use this library https://github.com/nim901/gfycat which right now I just downloaded the zip and extract it and put that in lib folder. 我打算使用这个库https://github.com/nim901/gfycat ,现在我刚刚下载了zip并解zip并将其放在lib文件夹中。 I have to checkin this library into the repo to work in Heroku. 我必须在这个库中签入repo才能在Heroku中工作。 Is there a way to install the lib automatically from github? 有没有办法从github自动安装lib?

You can add the library as a submodule of your project. 您可以将库添加为项目的子模块 This will allow you to update it like any other git repository. 这将允许您像任何其他git存储库一样更新它。

Is git clone https://github.com/nim901/gfycat.git and then git pull automatic enough? git clone https://github.com/nim901/gfycat.git然后git pull自动了吗? If this solution fits you and you need additional instructions, I will add them. 如果此解决方案适合您并且您需要其他说明,我将添加它们。

Heroku has support for git-backed python dependencies via pip: https://devcenter.heroku.com/articles/python-pip#git-backed-distributions Heroku通过pip支持git支持的python依赖: https//devcenter.heroku.com/articles/python-pip#git-backed-distributions

I believe this fits your requirements better than checking the actual libraries into git. 我认为这比将实际的库检入git更符合您的要求。 From the link above: 从上面的链接:

Anything that works with a standard pip requirements file will work as expected on Heroku. 任何适用于标准pip需求文件的东西都可以在Heroku上按预期工作。

Thanks to pip's Git support, you can install a Python package that is hosted on a remote Git repository. 感谢pip的Git支持,您可以安装托管在远程Git存储库上的Python包。

For example: 例如:

git+git://github.com/kennethreitz/requests.git

From how I'm reading your question, it sounds like you're trying to install the module to your system in order to be able to import it into projects and such. 从我如何阅读您的问题,听起来您正在尝试将模块安装到您的系统,以便能够将其导入项目等。

Download the zip, extract it to wherever, and open up a terminal window to the same directory. 下载zip,将其解压缩到任何地方,并打开一个终端窗口到同一目录。 Then just run python setup.py install from within the directory, and it should install into your system-wide site-packages directory for python. 然后从目录中运行python setup.py install ,它应该安装到python的系统范围的site-packages目录中。

I would have to recommend that you install it into it's own environment managed by virtualenv ( https://virtualenv.pypa.io/en/latest/ ), but it's not necessary. 我不得不建议您将它安装到virtualenvhttps://virtualenv.pypa.io/en/latest/ )管理的自己的环境中,但这不是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM