問題描述
使用 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
這篇關于如何使用 PIP 安裝具有不同名稱的 python 包的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!