简体   繁体   English

如何从Python中的import语句知道包或模块名称?

[英]How to know the package or module name from import statement in Python?

I have a python file and the developer of that code has left the organization. 我有一个python文件,该代码的开发人员离开了该组织。 When I run the code I get the following error. 当我运行代码时,我收到以下错误。

import dataAnalysis as DV ModuleNotFoundError: No module named 'dataAnalysis' 导入dataAnalysis为DV ModuleNotFoundError:没有名为'dataAnalysis'的模块

I provide below the brief snippet of the python file "main.py" below. 我在下面提供python文件“main.py”的简短片段。

import dataAnalysis as DV

def performCheck():
    ... other code
    ... other code
    i = DV.addGraph( pathplus)

Here my question is , how to know the actual module or package name of "dataAnalysis" from the above import statement so that I can make "pip install ". 这里我的问题是,如何从上面的import语句中知道“dataAnalysis”的实际模块或包名称,以便我可以进行“pip install”。 However, I tried to install DataAnalysis module, still it does not work. 但是,我试图安装DataAnalysis模块,但它仍然无法正常工作。

Is there any way to get the module or package name to install from the import statement in python ? 有没有办法从python的import语句中获取模块或包名称?

Go to console or terminal and run command pip install dataAnalysis . 转到控制台或终端并运行命令pip install dataAnalysis If permission denied, then make sure you have enough privilege to install a package. 如果权限被拒绝,请确保您具有足够的权限来安装程序包。

Update : In my opinion pip package DataAnalysis is a library that can be used for pre-processing a csv file. 更新 :在我看来,pip包DataAnalysis是一个可用于预处理csv文件的库。 As per your given code, it looks like adding a graph so may be it could be a local package. 根据您给定的代码,它看起来像添加图形,因此可能是本地包。 Check dataAnalysis folder in your project with __init__.py file inside. 使用__init__.py文件检查项目中的dataAnalysis文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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