如何更新从Git安装的Python自定义包版本?
解决Pipenv更新Git托管自定义Python包的问题
方法一:强制指定包更新
在测试项目的终端执行以下命令,强制拉取仓库最新代码并更新包:
pipenv install git+https://github.com/vincent2303/myCustomPackage.git#egg=myCustomPackage --upgrade
方法二:修改Pipfile后同步依赖
- 打开项目根目录的
Pipfile,找到对应包的配置行,确保格式为:
删掉可能存在的commit哈希、固定版本号等限制项。myCustomPackage = {git = "https://github.com/vincent2303/myCustomPackage.git", editable = false} - 执行同步命令清空缓存并重新拉取:
pipenv sync --dev --clear
方法三:卸载后重装
如果前两种方法无效,先卸载旧版本:
pipenv uninstall myCustomPackage
再重新安装最新版本:
pipenv install git+https://github.com/vincent2303/myCustomPackage.git#egg=myCustomPackage
关键注意事项
- 确认Git仓库已推送更新后的
setup.py(版本号0.0.2)和say_bar函数代码。 - 若之前用了
editable编辑模式安装包,本地代码会自动同步仓库更新;非编辑模式必须通过上述方法触发更新。
内容的提问来源于stack exchange,提问作者Vince M
相关产品推荐
相关产品推荐

