[Python] Why are some Python package names different than their import name?

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    Some packages are imported with a string which is different from the name of the package on PyPI, e.g.:

    $ pip list | grep -i "yaml\|qt"
    PyYAML 3.13
    QtPy 1.5.2

    • pyyaml (pip instal pyyaml), but import yaml
    • qtpy (pip install qtpy), yes import is qtpy but package is QtPy

    Several tools can't not handle that, e.g sphinx:

    $ make html
    WARNING: autodoc: failed to import module 'wireshark' from module 'logcollector.plugins'; the following exception was raised:
    No module named 'qtpy'


    I don't remember it right now, but same is for tools which scan the requirements.txt file and print warnings that the yaml package isn't installed (but it is and its name is pyyaml).

    Continue reading...

Compartilhe esta Página