Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some packages in python site-packages are not displayed

Python package list

These are the list of packages that are presented in my machine. When I tried to use the following python command to get the list the packages with its version, I was only able to see the packages jinja,jsonschema,markupsafe and matplotlib and the package "isapi" is missing.

>>> import pip
>>> ["%s==%s" % (i.key, i.version) for i in pip.utils.pkg_resources.working_set]

Result / Output:

['jinja2==2.7.3', 'jsonschema==2.5.1', 'markupsafe==0.23', 'matplotlib==1.4.3']

My requirement is to get that ("isapi") in the list too. Is there any option available ? Please provide your suggestions here.

Thanks in Advance :)

like image 833
Ramkumar Avatar asked Feb 09 '23 22:02

Ramkumar


1 Answers

isapi is not a PyPI package and was not installed with pip. You can see this since there is no folder for the package name with a .dist-info suffix.

The .dist-info folders1 are created by pip as part of the install process to store the meta information about the PyPI package. They essentially contain all the information about a package you can also find on the PyPI website. Next to those folders, pip will then add one for the actual package with the real package name2 that contains the real Python modules.

Since your isapi folder obviously did not come from a PyPI package, it came from another source. This could be for example an external setup utility that just installs the folder in there. It’s also possible that a different PyPI package installed the folder along as a dependency (not the case for your packages though). I suggest looking into the folder and the Python modules to get an idea what it does and where it could come from.

Anyway, since it was not installed with pip, pip obviously does not know about it. So it does not appear in the package list.

Unfortunately, there is no other good way to find out about that module programmatically. One possible way would be to simply get a directory listing of the site-packages folder and work through the modules that way. You could also use the pkgutil module to get a list of all modules (including built-in modules) and filter those out that are in the site-packages folder. But other than that, there is no other “registy” or something that will keep track of what is in that folder. And if you think about it, there can’t be one since you could always just drop a new folder in there on your own.


Foot notes:

1.dist-info folders were invented with PEP 376 as a way to unify the way distributions are managed.

2 Python packages are not required to be spelled exactly like PyPI packages. This allows for custom casing in the names for PyPI packages (since Python packages should be lower case), or even different names. For example, the PyPI package name for Beautiful Soup 4 is beautifulsoup4, but the Python package is just called bs4.

like image 145
poke Avatar answered Feb 13 '23 04:02

poke