简体   繁体   中英

How can I find out what package that a python module belongs to?

You are given some python source code with some import statements for modules that you don't recognize. You are curious and would like to know what packages these modules belong to.

2 scenarios.

Scenario #1:

Some of the imports fail because you don't have the correct packages installed.
You need figure out which package to install.
Is there a way to do this without leaving the command line?

Scenario #2:

It seems that you do have the modules installed already, but you are curious about which package they belong to.
Is there a way to discover this quickly and efficiently on the command line?

Normally a module from a package should be imported as:

import a.b

where a is the package and b is the module.

So the import statement should tell you what you need.

if modules are imported in odd way you can use:

from Tkinter import *
>>> Label
<class Tkinter.Label at 0x023F6768>
>>> Entry
<class Tkinter.Entry at 0x023F6650>

to see package

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM