Trouble installing Python dependencies during Netlify deployment: Rust and Cargo not found

I am experiencing issues while deploying my Django website on Netlify. The deployment fails during the installation of Python dependencies, specifically the django-minify-html 1.6.0 package. The error message suggests that Rust and Cargo are not found, and it prompts me to install them.

I have tried various solutions, including specifying the Rust toolchain and setting the PATH, but the problem persists.

Here is my build commnad rustup toolchain install stable && python distill-local --collectstatic --force

Has anyone encountered a similar problem during Netlify deployments? How did you resolve the issue with Rust and Cargo not being found? Any insights or alternative approaches would be greatly appreciated.
It’s a django static site export using django-distill as static site generator

Here is the error log for the help

9:08:38 PM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
9:08:30 PM: build-image version: c37eec0b0afc70685330eb5bac4f360432d87e96 (focal)
9:08:30 PM: buildbot version: c37eec0b0afc70685330eb5bac4f360432d87e96
9:08:30 PM: Fetching cached dependencies
9:08:30 PM: Starting to download cache of 65.3MB
9:08:31 PM: Finished downloading cache in 1.287s
9:08:31 PM: Starting to extract cache
9:08:32 PM: Finished extracting cache in 413ms
9:08:32 PM: Finished fetching cache in 1.745s
9:08:32 PM: Starting to prepare the repo for build
9:08:32 PM: Preparing Git Reference refs/heads/main
9:08:33 PM: Custom build command detected. Proceeding with the specified command: 'rustup toolchain install stable && bash && python distill-local public --collectstatic --force'
9:08:34 PM: Starting to install dependencies
9:08:34 PM: Python version set to 3.8
9:08:34 PM: Installing pip dependencies
9:08:34 PM: Started restoring cached pip cache
9:08:34 PM: Finished restoring cached pip cache
9:08:35 PM: Collecting asgiref==3.7.2
9:08:35 PM:   Using cached asgiref-3.7.2-py3-none-any.whl (24 kB)
9:08:35 PM: Requirement already satisfied: certifi==2023.5.7 in /opt/buildhome/python3.8/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (2023.5.7)
9:08:35 PM: Collecting charset-normalizer==3.1.0
9:08:35 PM:   Using cached charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (195 kB)
9:08:35 PM: Collecting Django==4.1.9
9:08:35 PM:   Using cached Django-4.1.9-py3-none-any.whl (8.1 MB)
9:08:36 PM: Processing /opt/buildhome/.cache/pip/wheels/fd/69/a3/f0cddee8dbf6b538b93281a2edf9c3468f2e44be7eb9eeddb2/django_distill-3.1.3-py3-none-any.whl
9:08:36 PM: Collecting django-minify-html==1.6.0
9:08:36 PM:   Downloading django_minify_html-1.6.0-py3-none-any.whl (6.9 kB)
9:08:36 PM: Collecting idna==3.4
9:08:36 PM:   Using cached idna-3.4-py3-none-any.whl (61 kB)
9:08:36 PM: Collecting minify_html==0.11.1
9:08:36 PM:   Downloading minify_html-0.11.1.tar.gz (136 kB)
9:08:36 PM:   Installing build dependencies: started
9:08:38 PM:   Installing build dependencies: finished with status 'done'
9:08:38 PM:   Getting requirements to build wheel: started
9:08:38 PM:   Getting requirements to build wheel: finished with status 'done'
9:08:38 PM:     Preparing wheel metadata: started
9:08:38 PM:     Preparing wheel metadata: finished with status 'error'
9:08:38 PM:     ERROR: Command errored out with exit status 1:
9:08:38 PM:      command: /opt/buildhome/python3.8/bin/python /tmp/tmpw4umi2q1 prepare_metadata_for_build_wheel /tmp/tmp_bdug7bf
9:08:38 PM:          cwd: /tmp/pip-install-p320mh05/minify-html
9:08:38 PM:     Complete output (8 lines):
9:08:38 PM:     error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
    help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.
9:08:38 PM:     Cargo, the Rust package manager, is not installed or is not on PATH.
9:08:38 PM:     This package requires Rust and Cargo to compile extensions. Install it through
9:08:38 PM:     the system's package manager or via
9:08:38 PM:     Checking for Rust toolchain....
9:08:38 PM:     ----------------------------------------
9:08:38 PM: ERROR: Command errored out with exit status 1: /opt/buildhome/python3.8/bin/python /tmp/tmpw4umi2q1 prepare_metadata_for_build_wheel /tmp/tmp_bdug7bf Check the logs for full command output.
9:08:38 PM: Error installing pip dependencies
9:08:38 PM: Build was terminated: dependency_installation script returned non-zero exit code: 1
9:08:38 PM: Failing build: Failed to install dependencies
9:08:38 PM: Finished processing build request in 8.532s

Here is the build command I setted up in netlify UI: rustup install stable && rustup default stable && python distill-local public --collectstatic --force
Thank you in advance for your help!

I’m not familiar with Python in this capacity but I think you should try updating you build. I also recommend you give this a support guide a read.