Installing multiple versions of a package with pip

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.

Leave a Comment