Home > Net >  Python. View the "import" name of a library
Python. View the "import" name of a library

Time:12-03

Some Python libraries are listed under one name in pip, but imported under a different name in the interpreter.

pycroptodome is a good example. In pip list, you see "pycryptodome". In a Python program, you have to call "import Crypto". "import pycryptodome" gives an error that the module doesn't exist.

Some libraries I've imported are giving me "module not found" errors. I want to see if they're imported under a different name from what appears in pip. Where can I find that data?

For reference, "pip show " and "pip inspect " don't seem to have this information.

CodePudding user response:

Usually in /lib/site-packages in your Python folder. (At least, on Windows.) You can use sys. path to find out what directories are searched for modules.

In the standard Python interpreter, you can type " help('modules') ". At the command-line, you can use pydoc modules . In a script, call pkgutil. iter_modules()

pydoc modules 

works

CodePudding user response:

go https://pypi.org/project/pycryptodome

download the tar file version you downloaded using pip and see the top-level view to see import names

  • Related