如何使用 PIP 安装具有不同名称的 python 包
问题描述
使用 PIP 安装新的 python 包时,我可以更改包名,因为有另一个包同名吗?
When installing a new python package with PIP, can I change the package name because there is another package with the same name?
或者,如何更改现有包的名称?
Or, how can I change the existing package's name?
解决方案
无法更改导入路径"(安装名称)通过指定 pip 的参数.所有其他选项都需要某种形式的更改包":
It's not possible to change "import path" (installed name) by specifying arguments to pip. All other options require some form of "changes to the package":
A.使用 pip install -e git+http://some_url#egg=some-name
:这样即使两个包的导入路径相同,它们也会保存在不同的目录下(使用 #egg=
之后提供的一些名称).在此之后,您可以转到包的源目录(通常是 venv/src/some-name
)并重命名一些文件夹以更改导入路径
A. Use pip install -e git+http://some_url#egg=some-name
: that way even if both packages have the same import path, they will be saved under different directories (using some-name
provided after #egg=
). After this you can go to the source directories of packages (usually venv/src/some-name
) and rename some folders to change import paths
B-C.Fork 存储库,进行更改,然后从该存储库安装包.或者您可以使用不同的名称在 PyPI 上发布您的包并按名称安装它
B-C. Fork the repository, make changes, then install the package from that repository. Or you can publish your package on PyPI using different name and install it by name
D.使用 pip download
将其中一个包放入您的项目中,然后根据需要重命名文件夹
D. use pip download
to put one of the packages in your project, then rename folders as you like
相关文章