如何在没有 pip 的情况下将来自 github 的库包含在 python 项目中?
How do I include library from github in python project without pip?
我不确定 python 包含来自 github 的另一个库的方法是什么。
我打算使用这个库 https://github.com/nim901/gfycat,我现在刚刚下载 zip
并将其解压缩并放入 lib
文件夹中。我必须将这个库签入回购协议才能在 Heroku 中工作。有没有办法从 github 自动安装库?
您可以将库添加为项目的 submodule。这将允许您像更新任何其他 git 存储库一样更新它。
git clone https://github.com/nim901/gfycat.git
然后 git pull
是否足够自动?如果此解决方案适合您并且您需要其他说明,我会添加它们。
从我对你问题的解读来看,你似乎在尝试将模块安装到你的系统中,以便能够将其导入到项目等中。
下载 zip,将其解压到任意位置,然后打开终端 window 到同一目录。然后只需从目录中 运行 python setup.py install
,它应该安装到 python 的系统范围 site-packages
目录中。
我不得不建议您将它安装到由 virtualenv
(https://virtualenv.pypa.io/en/latest/) 管理的自己的环境中,但这不是必需的。
Heroku 通过 pip 支持 git-backed python 依赖项:https://devcenter.heroku.com/articles/python-pip#git-backed-distributions
我相信这比将实际库签入 git 更符合您的要求。来自上面的link:
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
我不确定 python 包含来自 github 的另一个库的方法是什么。
我打算使用这个库 https://github.com/nim901/gfycat,我现在刚刚下载 zip
并将其解压缩并放入 lib
文件夹中。我必须将这个库签入回购协议才能在 Heroku 中工作。有没有办法从 github 自动安装库?
您可以将库添加为项目的 submodule。这将允许您像更新任何其他 git 存储库一样更新它。
git clone https://github.com/nim901/gfycat.git
然后 git pull
是否足够自动?如果此解决方案适合您并且您需要其他说明,我会添加它们。
从我对你问题的解读来看,你似乎在尝试将模块安装到你的系统中,以便能够将其导入到项目等中。
下载 zip,将其解压到任意位置,然后打开终端 window 到同一目录。然后只需从目录中 运行 python setup.py install
,它应该安装到 python 的系统范围 site-packages
目录中。
我不得不建议您将它安装到由 virtualenv
(https://virtualenv.pypa.io/en/latest/) 管理的自己的环境中,但这不是必需的。
Heroku 通过 pip 支持 git-backed python 依赖项:https://devcenter.heroku.com/articles/python-pip#git-backed-distributions
我相信这比将实际库签入 git 更符合您的要求。来自上面的link:
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