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

2024-06-11 02:08:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我不确定python使用什么方法来包含从github获取的另一个库。在

我计划使用这个库https://github.com/nim901/gfycat,现在我刚刚下载了zip并将其解压缩并放入lib文件夹中。我得把这个图书馆登记进回购系统才能在Heroku工作。有没有办法从github自动安装lib?在


Tags: 方法httpsgithub文件夹comheroku图书馆lib
3条回答

您可以将库添加为项目的submodule。这将允许您像任何其他git存储库一样更新它。在

git clone https://github.com/nim901/gfycat.git和{}是否足够自动?如果这个解决方案适合您,并且您需要附加说明,我将添加它们。在

Heroku通过pip:https://devcenter.heroku.com/articles/python-pip#git-backed-distributions支持git支持的python依赖项

我相信这比将实际的库检入git更符合您的需求。从上面的链接:

Anything that works with a standard pip requirements file will work as expected on Heroku.

Thanks to pip’s Git support, you can install a Python package that is hosted on a remote Git repository.

For example:

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

从我对你的问题的理解来看,听起来你是在尝试将模块安装到系统中,以便能够将其导入到项目中等等。在

下载zip文件,将其解压到任何地方,并打开同一目录的终端窗口。然后在目录中运行python setup.py install,它应该安装到python的系统范围的site-packages目录中。在

我建议您将其安装到由virtualenvhttps://virtualenv.pypa.io/en/latest/)管理的自己的环境中,但这不是必需的。在

相关问题 更多 >