Python: pipdeptree syntax introduction

I believe that when you follow some packages, you often encounter version incompatibility, but you don’t know the dependencies between versions. Today I will introduce a tool to you:pipdeptree< /span> is a Python package used to view installed pip packages and their dependencies. It displays the dependencies between packages in a tree structure, helping developers understand and manage project dependencies.
pipdeptree

Install:

1. Installation:

Use pip install pipdeptree command to install.

2. View all dependencies:

Use the pipdeptree command to view all installed packages and their dependencies.

3. View the dependencies of a specific package:

Use the pipdeptree -p <package_name> command to view the dependencies of a specific package.

4. Check which packages depend on a specific package:

Use the pipdeptree -r -p <package_name> command to see which packages depend on a specific package.

5. Generate requirements documents:

Using the pipdeptree --freeze command produces output similar to pip freeze but including dependency information.

for example:

Insert image description here

As you can see in the picture above, when I installed onnx==1...13.0, an incompatibility problem occurred. Note that the tensorboard and protobuf versions are incompatible. When I use pipdeptree -p onnx will display compatible tensorboard and protobuf versions. It can be seen that protubuf is too high for both tensorboard and onnx. At this time, we lower the protobuf version.
Insert image description here
When we install the protobuf version, we can find that the range of protobuf compatible with onnx: protobuf [required: >=3.20.2,<4, installed: 3.20.3] , so just reducing the scope of protobuf is not enough. At this time, we reduce the version of onnx. Insert image description here
When we reduce onnx to 1.12.0, when we install protobuf, it will not A compatibility error occurred. At this time, in pipdeptree -p onnx, you can see that protobuf is within the compatibility range. You can see a warning appears:

* twisted==23.10.0
 - zope-interface [required: >=5, installed: ?]

We can continue to follow the above process and first look at a compatible version of twisted. In fact, this zope.interface has already been installed, but I don’t know why twisted cannot recognize it. I tried to make it compatible with twisted again. zope.interface, but it still doesn't work, and it still can't be recognized.
zope.interface
Based on past experience, I feel that the twisted version may be too new. When I checked, it turned out to be
Insert image description here
So I tried to lower the version of twisted. You may have questions about which version twisted should be lowered to. My personal experience is that should be related to the version related to the package release time. This This is my personal experience, and it has always worked well. If there is a compatibility problem, if you install a package with a similar release time, there will be almost no compatibility problems. , I highly recommend everyone to try it. For example, twist has always had compatibility issues with zope.interface. We can check the release time of zope.interface5.5.2.
Insert image description here
As you can see, the twisted version that was released at a similar time to zope.interface5.5.2 is 22.10.0. So I downgraded to this version.
Insert image description here
You can see that pipdeptree -p twisted again, no incompatibility warnings appear.

Insights:

When there is incompatibility between packages, it is strongly recommended that everyone install versions with similar release times, and the release times should not be too far apart. This is what I have done in practice, and it has been solved perfectly every time. The longer the release time between dependent packages, the more likely incompatibility problems will occur. For example, the above twisted and zope.interface had compatibility issues a year after their release.

Guess you like

Origin blog.csdn.net/s1_0_2_4/article/details/135005251