DIFY Sandbox import requests ERROR #5470

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

Originally created by @mhanne0915 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

since 0.7.1 up to latest

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Steps to reproduce:

  • update to latest DIFY/Dify-sandbox version
  • python code block that uses requests library

✔️ Expected Behavior

Requests code should be successful.

Actual Behavior

Error:

Node Query Page run failed: Traceback (most recent call last): File "/tmp/code/73cdfa03_cbde_46de_a70a_ff9b8622b952.py", line 26, in ModuleNotFoundError: No module named 'requests' error: exit status 255

Originally created by @mhanne0915 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 since 0.7.1 up to latest ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Steps to reproduce: - update to latest DIFY/Dify-sandbox version - python code block that uses requests library ### ✔️ Expected Behavior Requests code should be successful. ### ❌ Actual Behavior Error: Node Query Page run failed: Traceback (most recent call last): File "/tmp/code/73cdfa03_cbde_46de_a70a_ff9b8622b952.py", line 26, in <module> ModuleNotFoundError: No module named 'requests' error: exit status 255
yindo added the 🐞 bug🌚 invalid labels 2026-02-21 18:11:07 -05:00
yindo closed this issue 2026-02-21 18:11:07 -05:00
Author
Owner

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

@mhanne0915 Hello there! I'm here to help you with bugs, answer questions, and even guide you on contributing. Let's tackle this issue together while we wait for a human maintainer.

I found a similar discussion and issue related to the ModuleNotFoundError for the requests library in the Dify sandbox environment.

  1. Similar Discussion:

  2. Similar Issue:

To resolve the ModuleNotFoundError for the requests library in your self-hosted Docker environment, you need to ensure that the requests package is included in the Docker image used for your services. Here are the steps:

  1. Modify the Dockerfile: Add the installation of requests in the Dockerfile used for your services. If you are using a custom Dockerfile, you can add the following line:

    RUN pip install requests
    
  2. Rebuild the Docker Image: After modifying the Dockerfile, rebuild the Docker image to include the new package.

    docker compose down
    docker compose build
    docker compose up -d
    
  3. Verify the Installation: Ensure that the requests package is installed correctly by checking the logs or running a test command inside the container.

Here is an example of how you might modify the Dockerfile:

# Example Dockerfile
FROM python:3.8-slim

# Install dependencies
RUN pip install --upgrade pip
RUN pip install requests

# Copy your application code
COPY . /app

# Set the working directory
WORKDIR /app

# Run the application
CMD ["python", "your_application.py"]

After making these changes, rebuild and restart your Docker containers as shown above. This should resolve the ModuleNotFoundError for requests [2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 9, 2024): <!-- Greeting --> @mhanne0915 Hello there! I'm here to help you with bugs, answer questions, and even guide you on contributing. Let's tackle this issue together while we wait for a human maintainer. <!-- Answer --> I found a similar discussion and issue related to the `ModuleNotFoundError` for the `requests` library in the Dify sandbox environment. 1. **Similar Discussion:** - [Sandbox import error: ModuleNotFoundError: No module named 'requests' error: exit status 255](https://github.com/langgenius/dify/discussions/4854) <sup>[[1]](https://github.com/langgenius/dify/discussions/4854)</sup>. 2. **Similar Issue:** - [SandBox import boto3 ModuleNotFoundError](https://github.com/langgenius/dify/issues/6601) (closed) <sup>[[2]](https://github.com/langgenius/dify/issues/6601)</sup>. To resolve the `ModuleNotFoundError` for the `requests` library in your self-hosted Docker environment, you need to ensure that the `requests` package is included in the Docker image used for your services. Here are the steps: 1. **Modify the Dockerfile**: Add the installation of `requests` in the Dockerfile used for your services. If you are using a custom Dockerfile, you can add the following line: ```dockerfile RUN pip install requests ``` 2. **Rebuild the Docker Image**: After modifying the Dockerfile, rebuild the Docker image to include the new package. ```bash docker compose down docker compose build docker compose up -d ``` 3. **Verify the Installation**: Ensure that the `requests` package is installed correctly by checking the logs or running a test command inside the container. Here is an example of how you might modify the Dockerfile: ```dockerfile # Example Dockerfile FROM python:3.8-slim # Install dependencies RUN pip install --upgrade pip RUN pip install requests # Copy your application code COPY . /app # Set the working directory WORKDIR /app # Run the application CMD ["python", "your_application.py"] ``` After making these changes, rebuild and restart your Docker containers as shown above. This should resolve the `ModuleNotFoundError` for `requests` <sup>[[2]](https://github.com/langgenius/dify/issues/6601)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

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

What's your sandbox version?

@crazywoola commented on GitHub (Sep 9, 2024): What's your sandbox version?
Author
Owner

@mhanne0915 commented on GitHub (Sep 11, 2024):

What's your sandbox version?

Hi @crazywoola, im using this version 0.2.6.

I havent tried yet the suggestion above to fix the issue. Will let you know once i tried the fix ;)

@mhanne0915 commented on GitHub (Sep 11, 2024): > What's your sandbox version? Hi @crazywoola, im using this version 0.2.6. I havent tried yet the suggestion above to fix the issue. Will let you know once i tried the fix ;)
Author
Owner

@yzning commented on GitHub (Sep 11, 2024):

What's your sandbox version?

meet the same problem in 0.2.7. Here is the error log:
/usr/local/lib/python3.10/site-packages/requests/__init__.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer). warnings.warn( meout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. json, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 768, in urlopen conn = self._get_conn(timeout=pool_timeout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. error: exit status 255

@yzning commented on GitHub (Sep 11, 2024): > What's your sandbox version? meet the same problem in 0.2.7. Here is the error log: /usr/local/lib/python3.10/site-packages/requests/__init__.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer). warnings.warn( meout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. json, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 768, in urlopen conn = self._get_conn(timeout=pool_timeout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. error: exit status 255
Author
Owner

@mhanne0915 commented on GitHub (Sep 11, 2024):

What's your sandbox version?

meet the same problem in 0.2.7. Here is the error log: /usr/local/lib/python3.10/site-packages/requests/init.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer). warnings.warn( meout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. json, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 768, in urlopen conn = self._get_conn(timeout=pool_timeout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. error: exit status 255

I also updated from 0.2.6 to 0.2.7 and i got the same problem.

@mhanne0915 commented on GitHub (Sep 11, 2024): > > What's your sandbox version? > > meet the same problem in 0.2.7. Here is the error log: /usr/local/lib/python3.10/site-packages/requests/**init**.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer). warnings.warn( meout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. json, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 768, in urlopen conn = self._get_conn(timeout=pool_timeout) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 294, in _get_conn return conn or self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1059, in _new_conn raise ImportError( ImportError: Can't connect to HTTPS URL because the SSL module is not available. error: exit status 255 I also updated from 0.2.6 to 0.2.7 and i got the same problem.
Author
Owner

@bountyhub-bot commented on GitHub (Sep 11, 2024):

🚀 Bounty Alert!

💰 A bounty of $10.00 has been created by Zyad1244 on BountyHub.

🔗 Claim this bounty by submitting a pull request that solves the issue!

Good luck, and happy coding! 💻

@bountyhub-bot commented on GitHub (Sep 11, 2024): ### 🚀 Bounty Alert! 💰 **A bounty of** $10.00 **has been created by** [Zyad1244](https://github.com/Zyad1244) **on BountyHub**. 🔗 **[Claim this bounty by submitting a pull request that solves the issue!](https://www.bountyhub.dev/bounty/view/ebaa6e65-49ce-4c7d-9f00-c15f4e3dd53c)** Good luck, and happy coding! 💻
Author
Owner

@zesen-lee commented on GitHub (Sep 12, 2024):

What's your sandbox version?你的沙盒版本是什么?

我是 0.2.7

@zesen-lee commented on GitHub (Sep 12, 2024): > What's your sandbox version?你的沙盒版本是什么? 我是 0.2.7
Author
Owner

@prd-tuong-nguyen commented on GitHub (Sep 13, 2024):

same problem

@prd-tuong-nguyen commented on GitHub (Sep 13, 2024): same problem
Author
Owner

@Yeuoly commented on GitHub (Sep 13, 2024):

Trying dify-sandbox:17bb213f2df4d34849e01ead55e6225be9e634a8 as a temporary solution.

@Yeuoly commented on GitHub (Sep 13, 2024): Trying dify-sandbox:17bb213f2df4d34849e01ead55e6225be9e634a8 as a temporary solution.
Author
Owner

@Yeuoly commented on GitHub (Sep 13, 2024):

Already fixed https://github.com/langgenius/dify-sandbox/pull/74

@Yeuoly commented on GitHub (Sep 13, 2024): Already fixed https://github.com/langgenius/dify-sandbox/pull/74
Author
Owner

@omarsoufiane commented on GitHub (Sep 13, 2024):

hello @Yeuoly , I'm the founder of bountyhub which is a new platform that aims to incentivize issue solving on GitHub, since you already fixed the issue, you can create an account and claim the bounty above.
let me know if you need any support.

@omarsoufiane commented on GitHub (Sep 13, 2024): hello @Yeuoly , I'm the founder of bountyhub which is a new platform that aims to incentivize issue solving on GitHub, since you already fixed the issue, you can create an account and claim the bounty above. let me know if you need any support.
Author
Owner

@ZPerling commented on GitHub (Sep 24, 2024):

@Yeuoly meet the same problem in 0.2.9. Here is the error log:

n error (_ssl.c:3093)
 call last):
  File \"/var/sandbox/sandbox-python/tmp/20fdff25_2f1d_4173_84b6_57e1b78327b9.py\", line 48, in <module>
  File \"<string>\", line 3, in <module>
  File \"/usr/local/lib/python3.10/site-packages/requests/__init__.py\", line 164, in <module>
    from .api import delete, get, head, options, patch, post, put, request
  File \"/usr/local/lib/python3.10/site-packages/requests/api.py\", line 11, in <module>
    from . import sessions
  File \"/usr/local/lib/python3.10/site-packages/requests/sessions.py\", line 15, in <module>
    from .adapters import HTTPAdapter
  File \"/usr/local/lib/python3.10/site-packages/requests/adapters.py\", line 80, in <module>
    _preloaded_ssl_context = create_urllib3_context()
  File \"/usr/local/lib/python3.10/site-packages/urllib3/util/ssl_.py\", line 292, in create_urllib3_context
    context = SSLContext(PROTOCOL_TLS_CLIENT)
  File \"/usr/local/lib/python3.10/ssl.py\", line 496, in __new__
    self = _SSLContext.__new__(cls, protocol)
ssl.SSLError: [SSL] unknown error (_ssl.c:3093)
error: exit status 255
@ZPerling commented on GitHub (Sep 24, 2024): @Yeuoly meet the same problem in 0.2.9. Here is the error log: ``` n error (_ssl.c:3093) call last): File \"/var/sandbox/sandbox-python/tmp/20fdff25_2f1d_4173_84b6_57e1b78327b9.py\", line 48, in <module> File \"<string>\", line 3, in <module> File \"/usr/local/lib/python3.10/site-packages/requests/__init__.py\", line 164, in <module> from .api import delete, get, head, options, patch, post, put, request File \"/usr/local/lib/python3.10/site-packages/requests/api.py\", line 11, in <module> from . import sessions File \"/usr/local/lib/python3.10/site-packages/requests/sessions.py\", line 15, in <module> from .adapters import HTTPAdapter File \"/usr/local/lib/python3.10/site-packages/requests/adapters.py\", line 80, in <module> _preloaded_ssl_context = create_urllib3_context() File \"/usr/local/lib/python3.10/site-packages/urllib3/util/ssl_.py\", line 292, in create_urllib3_context context = SSLContext(PROTOCOL_TLS_CLIENT) File \"/usr/local/lib/python3.10/ssl.py\", line 496, in __new__ self = _SSLContext.__new__(cls, protocol) ssl.SSLError: [SSL] unknown error (_ssl.c:3093) error: exit status 255 ```
Author
Owner

@NAMEs commented on GitHub (Nov 4, 2024):

dify-sandbox:0.2.10

Run failed: Traceback (most recent call last):
File "/var/sandbox/sandbox-python/tmp/cc1e92ba_db4b_4ea7_bf76_33bf3fbd7117.py", line 48, in
File "", line 17, in
File "", line 7, in main
TypeError: string indices must be integers
error: exit status 255

@NAMEs commented on GitHub (Nov 4, 2024): dify-sandbox:0.2.10 Run failed: Traceback (most recent call last): File "/var/sandbox/sandbox-python/tmp/cc1e92ba_db4b_4ea7_bf76_33bf3fbd7117.py", line 48, in File "", line 17, in File "", line 7, in main TypeError: string indices must be integers error: exit status 255
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5470