met error when use code_execuation #515

Closed
opened 2026-02-16 10:19:37 -05:00 by yindo · 2 comments
Owner

Originally created by @fanfan-lucky on GitHub (Aug 4, 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 Dify issues & Dify Official Plugins, 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.2.0

Plugin version

0.7.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I want to use "code execuation" to calculate the tokens of a string array, this string array is the output of "doc extract", but when I run this chat flow, the error "FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']" happend, please tell me how to resolve it.

the code is:

import tiktoken

def count_tokens(string_array):
encoder = tiktoken.get_encoding("cl100k_base")
total = 0
for s in string_array:
total += len(encoder.encode(s))
return total

def main(arg1: list[str]) -> dict:
result = count_tokens(arg1)
print(result)
return {"result": result}

✔️ Error log

No response

Originally created by @fanfan-lucky on GitHub (Aug 4, 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 [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/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.2.0 ### Plugin version 0.7.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I want to use "code execuation" to calculate the tokens of a string array, this string array is the output of "doc extract", but when I run this chat flow, the error "FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']" happend, please tell me how to resolve it. the code is: import tiktoken def count_tokens(string_array): encoder = tiktoken.get_encoding("cl100k_base") total = 0 for s in string_array: total += len(encoder.encode(s)) return total def main(arg1: list[str]) -> dict: result = count_tokens(arg1) print(result) return {"result": result} ### ✔️ Error log _No response_
yindo added the bug label 2026-02-16 10:19:37 -05:00
yindo closed this issue 2026-02-16 10:19:37 -05:00
Author
Owner

@fanfan-lucky commented on GitHub (Aug 4, 2025):

Image
@fanfan-lucky commented on GitHub (Aug 4, 2025): <img width="2756" height="1540" alt="Image" src="https://github.com/user-attachments/assets/d1e4fef0-db80-4bed-86e0-b4783c9f19cf" />
Author
Owner

@dosubot[bot] commented on GitHub (Aug 20, 2025):

Hi, @fanfan-lucky. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a FileNotFoundError in Dify 1.2.0 self-hosted via Docker when using the "code execution" plugin.
  • The error is related to missing or inaccessible temporary directories such as /tmp or /var/tmp.
  • This prevents token counting functionality from working properly.
  • You provided a screenshot for additional context.
  • No maintainer responses or solutions have been posted yet.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here.
  • If I don’t hear back within 5 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 20, 2025): Hi, @fanfan-lucky. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a FileNotFoundError in Dify 1.2.0 self-hosted via Docker when using the "code execution" plugin. - The error is related to missing or inaccessible temporary directories such as /tmp or /var/tmp. - This prevents token counting functionality from working properly. - You provided a screenshot for additional context. - No maintainer responses or solutions have been posted yet. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here. - If I don’t hear back within 5 days, I will automatically close this issue. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#515