使用pip安装软件包的多个版本 [英] Installing multiple versions of a package with pip
问题描述
在我的应用程序中,我想使用:
-
packageA
,需要packageX==1.3
-
packageB
,需要packageX==1.4
-
packageX==1.5
如何通过pip安装多个版本的packageX
来解决这种情况?
pip不会帮助您解决此问题.
您可以告诉它安装特定版本,但是它将覆盖另一个版本.另一方面,使用两个virtualenvs可以将两个版本安装在同一台计算机上,但不能同时使用.
最好的选择是手动安装这两个版本,方法是将它们以不同的名称放在Python路径中.
但是,如果您的两个库期望它们具有相同的名称(并且应该如此),则必须对其进行修改,以便它们使用一些导入别名来选择所需的版本,例如:
import dependencyname_version as dependencyname
目前尚无清除方法来执行此操作.您所希望的最好的办法就是使这种黑客工具正常工作.
我宁愿放弃两个库之一,而用一个等效库替换它,或者修补它以接受新版本的依赖关系并将修补程序返回给社区. p>
In my application I would like to use:
packageA
, which requirespackageX==1.3
packageB
, which requirespackageX==1.4
packageX==1.5
How can I install multiple versions of packageX
with pip to handle this situation?
pip won't help you with this.
You can tell it to install a specific version, but it will override the other one. On the other hand, using two virtualenvs will let you install both versions on the same machine, but not use them at the same time.
You best bet is to install both version manually, by putting them in your Python path with a different name.
But if your two libs expect them to have the same name (and they should), you will have to modify them so they pick up the version they need with some import alias such as:
import dependencyname_version as dependencyname
There is currently no clean way to do this. The best you can hope is for this hack to work.
I'd rather ditch one of the two libs and replace it with an equivalent, or patch it to accept the new version of the dependency and give the patch back to the community.
这篇关于使用pip安装软件包的多个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!