简体   繁体   English

错误:如何将方法从一个文件导入同一目录中的另一个文件

[英]Error: How to import method from one file to other in a same directory

I'm using python version 3.6.1 我正在使用python 3.6.1版本

I want to use method of one python file to another located in a same directory. 我想对同一个目录中的另一个使用python文件的方法。 I have used from utils import wit_response in app.py file. 我已经from utils import wit_response中使用了app.py文件。 And when I compile it this shows an error: 当我编译它时,这显示了一个错误:

Traceback (most recent call last): File "app.py", line 4, in from utils import wit_response File "E:\\Study\\Python\\fbmessengerbot\\utils.py", line 1, in from wit import Wit ModuleNotFoundError: No module named 'wit' 追溯(最近一次通话最后一次):文件“ app.py”,第4行,来自utils导入wit_response文件“ E:\\ Study \\ Python \\ fbmessengerbot \\ utils.py”,第1行,来自wit导入Wit ModuleNotFoundError:否名为“ wit”的模块

In utils.py file I'm using from wit import Wit . 在utils.py文件中,我正在使用from wit import Wit The wit package i have already installed. 我已经安装了机智软件包。

How can i resolve this. 我该如何解决。

Thanks in advance. 提前致谢。

If you are using a Virtual environment do pip freeze and check whether "wit" package is installed or not. 如果您使用的是虚拟环境,请冻结pip并检查是否已安装“ wit”软件包。 If "wit" is installed open ipython and check whether you can import the "wit" package. 如果安装了“ wit”,请打开ipython并检查是否可以导入“ wit”软件包。 If "wit" is not imported in ipython check if any dependency packages are need for "wit". 如果未在ipython中导入“ wit”,请检查“ wit”是否需要任何依赖包。

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

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