The custom plugin localization import was successful, but it cannot be used #12031

Closed
opened 2026-02-21 19:05:23 -05:00 by yindo · 13 comments
Owner

Originally created by @youdianzhizhuo on GitHub (Mar 24, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1、package my plugin
2、 import

✔️ Expected Behavior

Debugging can be successful, but importing the package locally will result in an error。

Actual Behavior

app/storage/cwd/xx/xx-dify-plugin-0.0.1@7dbd1819a40b2324a8cfca1f8eb1b22a0c375a3bba214932b33626f4b69ee32a/.venv/bin/python: Error while finding module specification for 'main.py' (ModuleNotFoundError: path attribute not found on 'main' while trying to find 'main.py'). Try using 'main' instead of 'main.py' as the module name.

Originally created by @youdianzhizhuo on GitHub (Mar 24, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1、package my plugin 2、 import ### ✔️ Expected Behavior Debugging can be successful, but importing the package locally will result in an error。 ### ❌ Actual Behavior app/storage/cwd/xx/xx-dify-plugin-0.0.1@7dbd1819a40b2324a8cfca1f8eb1b22a0c375a3bba214932b33626f4b69ee32a/.venv/bin/python: Error while finding module specification for 'main.py' (ModuleNotFoundError: __path__ attribute not found on 'main' while trying to find 'main.py'). Try using 'main' instead of 'main.py' as the module name.
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 19:05:23 -05:00
yindo closed this issue 2026-02-21 19:05:23 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 24, 2025):

The error you're encountering suggests that there might be an issue with how the main.py file is being referenced or structured in your plugin. Here are a few steps you can take to resolve this:

  1. Check the Module Name: Ensure that you are using main instead of main.py when specifying the module to be executed. This is because Python's module system expects the module name without the .py extension.

  2. Verify the Plugin Structure: Make sure that your main.py file is located in the root directory of your plugin package. The directory structure should be set up so that Python can recognize main as a module.

  3. Update the Import Path: If your main.py is not in the root directory, you may need to adjust the import path or move the file to the correct location.

  4. Check for __init__.py: If your main.py is inside a package (a directory), ensure that there is an __init__.py file in the same directory. This file can be empty but is necessary for Python to treat the directory as a package.

  5. Repackage the Plugin: After making these changes, repackage your plugin and try importing it again.

These steps should help resolve the ModuleNotFoundError related to the main.py file in your Dify plugin.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 24, 2025): <!-- Answer --> The error you're encountering suggests that there might be an issue with how the `main.py` file is being referenced or structured in your plugin. Here are a few steps you can take to resolve this: 1. **Check the Module Name**: Ensure that you are using `main` instead of `main.py` when specifying the module to be executed. This is because Python's module system expects the module name without the `.py` extension. 2. **Verify the Plugin Structure**: Make sure that your `main.py` file is located in the root directory of your plugin package. The directory structure should be set up so that Python can recognize `main` as a module. 3. **Update the Import Path**: If your `main.py` is not in the root directory, you may need to adjust the import path or move the file to the correct location. 4. **Check for __init__.py**: If your `main.py` is inside a package (a directory), ensure that there is an `__init__.py` file in the same directory. This file can be empty but is necessary for Python to treat the directory as a package. 5. **Repackage the Plugin**: After making these changes, repackage your plugin and try importing it again. These steps should help resolve the `ModuleNotFoundError` related to the `main.py` file in your Dify plugin. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/92a36815-d1b3-47f5-ab4c-f4301f0ec8af?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Mar 24, 2025):

Can you provide detailed steps of packaging the plugin?

@crazywoola commented on GitHub (Mar 24, 2025): Can you provide detailed steps of packaging the plugin?
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

能否提供一下插件打包的详细步骤呢?

Image

@youdianzhizhuo commented on GitHub (Mar 24, 2025): > 能否提供一下插件打包的详细步骤呢? ![Image](https://github.com/user-attachments/assets/f8406970-037f-4b8b-95ad-6cd5f8bf0b59)
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

Image

@youdianzhizhuo commented on GitHub (Mar 24, 2025): ![Image](https://github.com/user-attachments/assets/e5d035e1-c0a6-44c6-bd69-64863b065cd9)
Author
Owner

@crazywoola commented on GitHub (Mar 24, 2025):

What's the version of the plugin sdk?

@crazywoola commented on GitHub (Mar 24, 2025): What's the version of the plugin sdk?
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

插件 sdk 的版本是多少?

latest

@youdianzhizhuo commented on GitHub (Mar 24, 2025): > 插件 sdk 的版本是多少? latest
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

What's the version of the plugin sdk?

0.0.6

@youdianzhizhuo commented on GitHub (Mar 24, 2025): > What's the version of the plugin sdk? 0.0.6
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

ImageThis is the successful effect during debugging

@youdianzhizhuo commented on GitHub (Mar 24, 2025): ![Image](https://github.com/user-attachments/assets/955b87a3-fd42-4d31-8ebd-ca3f3d85250e)This is the successful effect during debugging
Author
Owner

@crazywoola commented on GitHub (Mar 24, 2025):

Do you have a link to this repo?

@crazywoola commented on GitHub (Mar 24, 2025): Do you have a link to this repo?
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

您有这个 repo 的链接吗?

https://github.com/youdianzhizhuo/mysql-dify-plugin

@youdianzhizhuo commented on GitHub (Mar 24, 2025): > 您有这个 repo 的链接吗? https://github.com/youdianzhizhuo/mysql-dify-plugin
Author
Owner

@crazywoola commented on GitHub (Mar 24, 2025):

 ~/Program/mysql-dify-plugin/ [main] pwd
/Users/crazywoola/Program/mysql-dify-plugin
 ~/Program/mysql-dify-plugin/ [main] ..
 ~/Program/ dify plugin package mysql-dify-plugin
2025/03/24 15:34:25 package.go:39: [INFO]plugin packaged successfully, output path: mysql-dify-plugin.difypkg
-rw-r--r--@  1 crazywoola  staff    29K  3 24 15:34 mysql-dify-plugin.difypkg

I can not reproduce this behavior. I suggest you checking the python related environments.

@crazywoola commented on GitHub (Mar 24, 2025): ```  ~/Program/mysql-dify-plugin/ [main] pwd /Users/crazywoola/Program/mysql-dify-plugin  ~/Program/mysql-dify-plugin/ [main] ..  ~/Program/ dify plugin package mysql-dify-plugin 2025/03/24 15:34:25 package.go:39: [INFO]plugin packaged successfully, output path: mysql-dify-plugin.difypkg ``` ``` -rw-r--r--@ 1 crazywoola staff 29K 3 24 15:34 mysql-dify-plugin.difypkg ``` I can not reproduce this behavior. I suggest you checking the python related environments.
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

 ~/Program/mysql-dify-plugin/ [main] pwd
/Users/crazywoola/Program/mysql-dify-plugin
 ~/Program/mysql-dify-plugin/ [main] ..
 ~/Program/ dify plugin package mysql-dify-plugin
2025/03/24 15:34:25 package.go:39: [INFO]plugin packaged successfully, output path: mysql-dify-plugin.difypkg
-rw-r--r--@  1 crazywoola  staff    29K  3 24 15:34 mysql-dify-plugin.difypkg

I can not reproduce this behavior. I suggest you checking the python related environments.

The packaging was successful, but it is actually unusable and can only be used during debugging

@youdianzhizhuo commented on GitHub (Mar 24, 2025): > ``` >  ~/Program/mysql-dify-plugin/ [main] pwd > /Users/crazywoola/Program/mysql-dify-plugin >  ~/Program/mysql-dify-plugin/ [main] .. >  ~/Program/ dify plugin package mysql-dify-plugin > 2025/03/24 15:34:25 package.go:39: [INFO]plugin packaged successfully, output path: mysql-dify-plugin.difypkg > ``` > > ``` > -rw-r--r--@ 1 crazywoola staff 29K 3 24 15:34 mysql-dify-plugin.difypkg > ``` > > I can not reproduce this behavior. I suggest you checking the python related environments. The packaging was successful, but it is actually unusable and can only be used during debugging
Author
Owner

@youdianzhizhuo commented on GitHub (Mar 24, 2025):

set file update entrypoint value main.py to main

@youdianzhizhuo commented on GitHub (Mar 24, 2025): set file update entrypoint value main.py to main
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12031