如何找到“进口名称"Python中的任何包?

How to find quot;import namequot; of any package in Python?(如何找到“进口名称Python中的任何包?)
本文介绍了如何找到“进口名称"Python中的任何包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想知道是否有任何可靠且一致的方法来获取 Python 包的导入名称"/命名空间.例如;

I wonder if is there any reliable and consistant way to get a Python package's "import name" / namespace. For example;

;django 干草堆
进口名称;干草堆

Package; django-haystack
Import name; haystack

;ipython
进口名称;IPython

Package; ipython
Import name; IPython

到目前为止,我知道,PyPi 不存储我使用 PyPiXmlRpc 检查过的信息.

So far I know, PyPi doesn't store that information that I've checked with PyPiXmlRpc.

我还尝试自动下载包、解压缩并挖掘 .egg-info,但有些包根本没有那个文件夹.

I also tried to automate to download the package, extract it and dig the .egg-info but some packages doesn't have that folder at all.

任何帮助将不胜感激,并将用于一个礼貌的小工具:)

Any help will be appreciated and will be used for a good-manner gadget :)

推荐答案

注意这里所说的包不是包,而是发行版.一个发行版可以包含零个或多个模块或包.这意味着分发包与包之间没有一对一的映射.

Note that what you call a package here is not a package but a distribution. A distribution can contain zero or more modules or packages. That means there is no one-to-one mapping of distributions to packages.

我不确定是否有办法检测发行版将安装哪些模块和包,而不是实际安装它并检查新添加的包、模块和 pth 文件的文件系统更改.

I'm not sure there is a way to detect what modules and packages will be installed by a distribution, other than actually installing it and introspect filesystem changes for newly added packages, modules and pth files.

这篇关于如何找到“进口名称"Python中的任何包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)