Unable to execute python code block base64 module not found #5483

Closed
opened 2026-02-21 18:11:11 -05:00 by yindo · 2 comments
Owner

Originally created by @siddhantprateek on GitHub (Sep 9, 2024).

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

main

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Insert a code block
  2. Attempt to run it.

✔️ Expected Behavior

The code should get executed.

Actual Behavior

Screenshot 2024-09-09 at 3 05 18 PM
Screenshot 2024-09-09 at 3 05 02 PM

I'm assuming that base64 is installed by default and there are no external dependencies in the code I am running. However, I'm still encountering the following error: ModuleNotFoundError: No module named 'base64'

Originally created by @siddhantprateek on GitHub (Sep 9, 2024). ### 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 main ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Insert a code block 2. Attempt to run it. ### ✔️ Expected Behavior The code should get executed. ### ❌ Actual Behavior ![Screenshot 2024-09-09 at 3 05 18 PM](https://github.com/user-attachments/assets/f1fa7f42-e809-4890-9049-c221e7a8d1f3) ![Screenshot 2024-09-09 at 3 05 02 PM](https://github.com/user-attachments/assets/9bcd9ff9-7e33-42ef-b08a-4a57ff3c869b) I'm assuming that base64 is installed by default and there are no external dependencies in the code I am running. However, I'm still encountering the following error: `ModuleNotFoundError: No module named 'base64'`
yindo added the 🐞 bug label 2026-02-21 18:11:11 -05:00
yindo closed this issue 2026-02-21 18:11:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 9, 2024):

Hey there, @siddhantprateek! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. I'm like your personal assistant, but in bot form.

The base64 module is a standard Python library and should be available by default. However, there might be custom configurations or issues in the Dify environment affecting its availability.

Here are a few steps to troubleshoot and resolve the issue:

  1. Verify Python Environment: Ensure that the Python environment within the Docker container is correctly set up and includes the standard libraries.

    docker exec -it <container_id> python -c "import base64; print('base64 module is available')"
    
  2. Check Custom Configurations: Review any custom scripts or configurations that might override or affect the default Python environment settings. For example, Dify uses custom environment variable settings and gevent monkey patching, which might impact the environment [1].

  3. Rebuild Docker Image: Sometimes, rebuilding the Docker image can resolve issues related to missing libraries.

    docker-compose down
    docker-compose build
    docker-compose up -d
    
  4. Inspect Dockerfile: Ensure that the Dockerfile used for building the image does not exclude standard libraries. If you have a custom Dockerfile, verify that it includes the necessary base image and dependencies.

If the issue persists, you might want to check for any known issues or bugs related to the Python environment setup in the Dify self-hosted Docker configuration [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 9, 2024): <!-- Greeting --> Hey there, @siddhantprateek! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. I'm like your personal assistant, but in bot form. <!-- Answer --> The `base64` module is a standard Python library and should be available by default. However, there might be custom configurations or issues in the Dify environment affecting its availability. Here are a few steps to troubleshoot and resolve the issue: 1. **Verify Python Environment**: Ensure that the Python environment within the Docker container is correctly set up and includes the standard libraries. ```bash docker exec -it <container_id> python -c "import base64; print('base64 module is available')" ``` 2. **Check Custom Configurations**: Review any custom scripts or configurations that might override or affect the default Python environment settings. For example, Dify uses custom environment variable settings and gevent monkey patching, which might impact the environment <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/app.py)</sup>. 3. **Rebuild Docker Image**: Sometimes, rebuilding the Docker image can resolve issues related to missing libraries. ```bash docker-compose down docker-compose build docker-compose up -d ``` 4. **Inspect Dockerfile**: Ensure that the Dockerfile used for building the image does not exclude standard libraries. If you have a custom Dockerfile, verify that it includes the necessary base image and dependencies. If the issue persists, you might want to check for any known issues or bugs related to the Python environment setup in the Dify self-hosted Docker configuration <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/app.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Sep 9, 2024):

Please upgrade sandbox to v0.2.6

@crazywoola commented on GitHub (Sep 9, 2024): Please upgrade sandbox to v0.2.6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5483