Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python packages with conflicting dependencies

we are trying to install several own written python3 applications sharing some libraries with conflicting versions.

We are currently discussing employing the order of packages inside the PYTHONPATH and/ or pythons virtualenv.

How would you handle this?

like image 657
Rollmops Avatar asked Apr 08 '16 12:04

Rollmops


People also ask

What is a dynamic dependency conflict in Python?

Dependency conflicts occur when different Python packages have the same dependency, but depend on different and incompatible versions of that shared package. Because only a single version of a dependency is permitted in any project’s environment, finding a compatible solution can be difficult.

How do I list all dependencies of a Python package?

Instead, package dependencies can be seen using one of the following commands in Python: pip show: List dependencies of Python packages that have already been installed. pipdeptree: List the dependencies in a tree form. Pip list: List installed packages with various conditions.

What is a version conflict in Python?

These dependencies can have their own dependencies, resulting in a complicated dependency tree. If you’re building an application with Python and two packages require different versions of the same package, then Python will have a version conflict and your project may not build!

What are the different dependency management tools in Python?

There are many different dependency management tools and methods for managing and adding dependencies to a Python project, from pip to Conda to the ActiveState Platform. Here’s a summary of some of the most popular dependency management tools. Pip is the de facto standard tool for installing Python packages and managing their dependencies.


1 Answers

You can use pipx.

pipx will do all the work of setting up separate virtual environments for each application, so that all the applications' dependencies remain separate.

If you use virtualenv yourself, you have to switch environments to run a different application. pipx handles the environment for you, so you don't have to mess with the virtualenvs at all.

From the docs:

pipx is made specifically for application installation, as it adds isolation yet still makes the apps available in your shell: pipx creates an isolated environment for each application and its associated packages.

Old Answer (pipsi is no longer maintained, but pipx is almost identical in usage)

You can use pipsi.

pipsi will do all the work of setting up separate virtual environments for each application, so that all the applications' dependencies remain separate.

If you use virtualenv yourself, you have to switch environments to run a different application. pipsi handles the environment for you, so you don't have to mess with the virtualenvs at all.

From the docs:

If you are installing Python packages globally for cli access, you almost certainly want to use pipsi instead of running sudo pip .... so that you get

  • Isolated dependencies to guarantee no version conflicts
  • The ability to install packages globally without using sudo
  • The ability to uninstall a package and its dependencies without affecting other globally installed Python programs
like image 121
jpyams Avatar answered Sep 28 '22 15:09

jpyams