How to install python package with a different name using PIP(如何使用 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
这篇关于如何使用 PIP 安装具有不同名称的 python 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 PIP 安装具有不同名称的 python 包
基础教程推荐
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
