dify icon indicating copy to clipboard operation
dify copied to clipboard

The code execution unit in the workflow of dify cloud Version 0.6.12-fix1 is unable to use the "requests" library properly

Open ouni3 opened this issue 1 year ago • 4 comments

Self Checks

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

Dify version

0.6.12-fix1

Cloud or Self Hosted

Cloud

Steps to reproduce

import requests

def main() -> dict:
    response = requests.get('https://www.baidu.com/')
    if response.status_code == 200:
        result = "123"
    else:
        result="  "
    return {
        "result": result,
    }
搜狗截图20240706230904 搜狗截图20240706230931

✔️ Expected Behavior

success work

❌ Actual Behavior

runtime error:/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(

ouni3 avatar Jul 06 '24 15:07 ouni3

To resolve the RequestsDependencyWarning due to missing character detection dependencies (chardet or charset_normalizer) in the code execution unit of Dify Cloud Version 0.6.12-fix1, you need to install the missing dependencies. Here is how you can do it:

  1. Install chardet or charset_normalizer using pip:

    pip install chardet
    

    or

    pip install charset_normalizer
    
  2. Add the dependencies to your Docker setup:

    If you are using Docker, you can add the dependencies to your Dockerfile. Here is an example of how to modify your Dockerfile to include chardet:

    FROM python:3.8-slim
    
    # Install dependencies
    RUN pip install chardet
    
    # Copy your application code
    COPY . /app
    
    # Set the working directory
    WORKDIR /app
    
    # Run your application
    CMD ["python", "your_application.py"]
    
  3. Rebuild and restart your Docker containers:

    docker compose down
    docker compose build
    docker compose up -d
    

By following these steps, you should be able to resolve the RequestsDependencyWarning by ensuring that the necessary character detection dependencies are installed [1].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Jul 06 '24 15:07 dosubot[bot]

Does this issue exists in earlier version?

Yeuoly avatar Jul 07 '24 09:07 Yeuoly

Does this issue exists in earlier version? no,i can use it correctly in 2024/06/25.

ouni3 avatar Jul 07 '24 11:07 ouni3

get the same issue on 0.6.14 image

elvis-cai avatar Jul 24 '24 09:07 elvis-cai

Is the only way to modify the Dockerfile as an OSS contributor to resolve this error on Dify Cloud?

hiyasichuka avatar Jul 28 '24 01:07 hiyasichuka

Version 0.7.0 has the same problem

hanhaiszw avatar Aug 15 '24 03:08 hanhaiszw

I had the same problem. Any way to figure it out?

Kevin9703 avatar Aug 15 '24 10:08 Kevin9703

Get the same issue on api-0.7.1 and sandbox-0.2.6 @Yeuoly TOT

pyxsqbs avatar Aug 20 '24 03:08 pyxsqbs

Get the same issue on api-0.7.1 and sandbox-0.2.6 @Yeuoly TOT

I suggest using httpx instead, it's a requests alternative solution and it works better.

Yeuoly avatar Aug 20 '24 05:08 Yeuoly

Why this issue be closed, I have the same problem.

X4tar avatar Sep 05 '24 03:09 X4tar