简体   繁体   English

在 Rasa Chatbot 中导入 python model 后目录未找到模块错误

[英]Module Not Found Error for Directory after importing python model in Rasa Chatbot

So I tried a majority of the solutions on this platform and none of it worked.所以我尝试了这个平台上的大部分解决方案,但都没有用。 Im desperately in need of help.我迫切需要帮助。

I'm using Rasa Chatbot in my project and im trying to use actions.我在我的项目中使用 Rasa Chatbot,我正在尝试使用操作。 In actions im trying to call a getAllProducts function from the negotiate.py python file in my backend directory.在操作中,我试图从后端目录中的 negotiate.py python 文件调用 getAllProducts function。 My project file structure looks like this.我的项目文件结构如下所示。

在此处输入图像描述

and I import the function like this in actions.py我在 actions.py 中像这样导入 function

在此处输入图像描述

Ill be calling the function as follows我将按如下方式拨打 function

在此处输入图像描述

but im getting the following error when I try to execute this in rasa,但是当我尝试在 rasa 中执行此操作时出现以下错误, 在此处输入图像描述

How can I fix this error?我该如何解决这个错误?

You can go back in an import only inside a module with the __init__ file.您可以 go 仅在具有__init__文件的模块内导入。 If you want to do import negotiate as nego you must put the file negotiate.py inside the action directory of rasa chatbot.如果你想将 import negotiate as nego 导入,你必须将文件 negotiate.py 放在 rasa chatbot 的 action 目录中。 If you don't want to do it, you must use如果你不想这样做,你必须使用

import os
import sys; sys.path.insert(1, os.path.join(sys.path[0], '../..'))

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

相关问题 使用python的Rasa chatbot中的Unicode错误 - Unicode error in Rasa chatbot using python 未找到模块错误 - 从同级目录导入 - Module Not Found Error - Importing from sibling directory Django:模块未找到错误,导入模型时 - Django: Module not found error , on importing a model Python 错误:未找到模块,即使在将目录添加到 PATH 后也是如此 - Python error : No module found, even after adding directory to PATH 将RASA与Python和Flask结合使用的聊天机器人 - Chatbot using RASA with Python and Flask 移动目录后未找到Python模块问题 - Python Module Not Found Issues after moving directory 在 python 中导入时安装熊猫后错误:模块“os”没有属性“add_dll_directory” - after installing panda while importing in python Error: module 'os' has no attribute 'add_dll_directory' Python目录/模块结构和导入 - Python directory/module structure and importing 使用 Z469A31FD9D773110F14057BAECCDDD25Z 的 Rasa 自定义操作服务器中未找到模块错误 - Module Not Found Error in Rasa Custom Action Server using DOCKER 在/ home目录外导入时,Python中出现“未命名模块”错误 - 'No module named' error in Python while importing outside /home directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM