第三方庫的使用
1. 問題
一般使用pip install package_name
直接從官方PyPi獲取,但有些庫官方也只是保持在某些版本。如果有一些Bug修復或者有人根據自己需求新增了一些功能並且Pull requests
到了Github上,但是還沒有被作者或官方收錄,那么該如何從Github上去安裝?
2. 解決
通過搜索pip documentation,在其Support下的Git中有以下示例:
[-e] git+http://git.example.com/MyProject#egg=MyProject
[-e] git+https://git.example.com/MyProject#egg=MyProject
[-e] git+ssh://git.example.com/MyProject#egg=MyProject
[-e] git+file:///home/user/projects/MyProject#egg=MyProject
如使用pip install git+http://git.example.com/MyProject#egg=MyProjec
即可從已有的Github倉庫鏈接安裝,注意末尾別少了#egg項目名稱。
同時,還可以指定分支或者標簽
[-e] git+https://git.example.com/MyProject.git@main#egg=MyProject