Help! - ModuleNotFoundError: No module named 'distutils'

I met a error “distutils”…
I searched some blogs and Streamlit topics, but I cannot found the solution.
I changed python version from 3.12 to 3.10, 3.9…
and install setuptools…
But it didn’t works(Cannot deploy).
Plz help me…

  1. Share the link to the public app
    (https://kb-hrd-chatbot-selfapi.streamlit.app/)

  2. Share the link to your app’s public GitHub repository
    (GitHub - Jason-Mati/KB_HRD_Chatbot_SelfAPI)

  3. Share the full text of the error message
    import distutils.core
    ModuleNotFoundError: No module named ‘distutils’
    [notice] A new release of pip is available: 24.0 → 24.2
    [notice] To update, run: pip install --upgrade pip
    Checking if Streamlit is installed
    ────────────────────────────────────────────────────────────────────────────────────────
    [12:31:39] :exclamation: installer returned a non-zero exit code

  4. Share the Streamlit and Python versions.
    (streamlit==1.27.2, python==3.9, 3.10, 3.11, 3.12)

  5. OS === MacOS

I was able to deploy your code using python 3.11.

No, the OS in streamlit cloud is Debian bookworm.

I changed python version 3.11,
but it is not working T.T…
스크린샷 2024-08-19 오후 10.58.49

Apparently you have python 3.11 in your Mac, but Streamlit Cloud does not know or care about it.

And then… How can I fix this? …

When deploying a new app in Community Cloud, go to Advance Settings to select the Python version to use. It defaults to 3.12

Thanks to give me a solution. But I cannot found the menu ‘Advanced settings’.

I found the menu, and change the python version. But it is not working yet…

Hi @Jason6
distutils is marked as deprecated PEP 632 – Deprecate distutils module | peps.python.org and will be removed from Python.
If you want your app to run Python 3.12 consider moving to setuptools

Thank you so much for your advice.

Is there any plan for Streamlit to fix the error associated with distutils that have been used in Python’s past version? This means that we have to use Python’s past version because of this…

After Python 3.12 it will continue to be a later version, and I don’t think it’s right to keep this problem going, and even in the Advanced Settings settings section, the official Streamlit document explains that you can use Python 3.12 to distribute it, but there seems to be a problem…

The error I had when trying to deploy your code with python 3.12 was unrelated to streamlit. It was due to numpy==1.25.2, which is too old.

There is nothing to fix in streamlit, you just need a more recent numpy if you want to use python 3.12.

Thank you for your advice. I will try to fix it.

I’m not a programmer, but just office man(HRD part). I’m trying to make a education course with streamlit platform. So, I want to inform you of the easy distribution process through the Streamlit platform after basic Python learning. However, from the perspective of general office workers, not programmers, errors that occur during the distribution process may occur, but it seems that the explanation such as how to resolve this error and what version should be changed to if it is wrong is not properly guided.

For example, this case is called the “distutils” problem in the error guide, and correcting it according to the solution in the error message does not solve this problem, and it does not solve it by trying to solve it through a variety of solutions that can be found in various other documents.

Upgrading the numpy version doesn’t solve it either.

I hope it’s a platform that’s easy to use from a non-developer’s point of view… (especially in the context of this error)

[Error Message]

ModuleNotFoundError: No module named 'distutils'

[notice] A new release of pip is available: 24.0 → 24.2

[notice] To update, run: pip install --upgrade pip

Unfortunately it is not feasible to anticipate every possible cause for an error. ModuleNotFoundError usually means that you need to install the missing package. But in this case it means that you are trying to install the wrong version of some package. The logs should tell you what package is causing the issue.

You still have the same numpy==1.25.2 in your requirements file. That won’t work with python 3.12.

I tried to change numpy version.
But it makes another problems…(crash with another packages…)

So I stopped fixing now…TT

2024년 8월 20일 (화) 오후 10:57, Goyo via Streamlit <notifications@streamlit.discoursemail.com>님이 작성:

I want to know the requirements.txt to deploy an responsible ai code,i doent know the correct version to install it

That depends on the code.

Thanks for your comment. Here is the “requirements.txt” like below.

aiofiles==23.2.1
aiohttp==3.8.5
aiosignal==1.3.1
altair==5.1.1
annotated-types==0.5.0
antlr4-python3-runtime==4.9.3
anyio==3.7.1
appnope==0.1.3
asttokens==2.4.0
async-timeout==4.0.3
attrs==23.1.0
backcall==0.2.0
backoff==2.2.1
bcrypt==4.0.1
beautifulsoup4==4.12.2
black==23.9.1
blinker==1.6.2
blis==0.7.10
Brotli==1.1.0
cachetools==5.3.1
catalogue==2.0.9
certifi==2023.7.22
cffi==1.15.1
chardet==5.2.0
charset-normalizer==3.2.0
chroma-hnswlib==0.7.3
chromadb==0.4.11
click==8.1.7
coloredlogs==15.0.1
comm==0.1.4
confection==0.1.3
contourpy==1.1.1
cryptography==41.0.4
cycler==0.11.0
cymem==2.0.8
dataclasses-json==0.5.14
debugpy==1.8.0
decorator==5.1.1
dill==0.3.7
dnspython==2.4.2
duckduckgo-search==3.8.5
EbookLib==0.18
effdet==0.4.1
elastic-transport==8.4.0
elasticsearch==8.9.0
email-validator==2.0.0.post2
emoji==2.8.0
et-xmlfile==1.1.0
executing==1.2.0
faiss-cpu==1.7.4
fastapi==0.99.1
ffmpeg==1.4
ffmpeg-python==0.2.0
filelock==3.12.4
filetype==1.2.0
flatbuffers==23.5.26
fonttools==4.42.1
frozenlist==1.4.0
fsspec==2023.9.1
future==0.18.3
gitdb==4.0.10
GitPython==3.1.35
gpt4all==2.0.2
greenlet==3.0.0
h11==0.14.0
h2==4.1.0
hpack==4.0.0
html2text==2020.1.16
httpcore==0.18.0
httptools==0.6.0
httpx==0.25.0
huggingface-hub==0.16.4
humanfriendly==10.0
hyperframe==6.0.1
idna==3.4
importlib-metadata==6.8.0
importlib-resources==6.0.1
iopath==0.1.10
ipykernel==6.25.2
ipython==8.15.0
itsdangerous==2.1.2
jedi==0.19.0
Jinja2==3.1.2
joblib==1.3.2
jsonpatch==1.33
jsonpointer==2.4
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
jupyter_client==8.3.1
jupyter_core==5.3.1
kiwisolver==1.4.5
langchain==0.0.332
langcodes==3.3.0
langsmith==0.0.52
layoutparser==0.3.4
loguru==0.7.2
lxml==4.9.3
manifest-ml==0.0.1
Markdown==3.4.4
markdown-it-py==3.0.0
MarkupSafe==2.1.3
marshmallow==3.20.1
matplotlib==3.8.0
matplotlib-inline==0.1.6
mdurl==0.1.2
monotonic==1.6
mpmath==1.3.0
msg-parser==1.2.0
multidict==6.0.4
murmurhash==1.0.10
mypy-extensions==1.0.0
nest-asyncio==1.5.8
networkx==3.1
nltk==3.8.1
numexpr==2.8.5
numpy==1.25.2
olefile==0.46
omegaconf==2.3.0
onnx==1.14.1
onnxruntime==1.16.0
openai
opencv-python==4.8.0.76
openpyxl==3.1.2
orjson==3.9.9
overrides==7.4.0
packaging==23.1
pandas==2.1.0
parso==0.8.3
pathspec==0.11.2
pathy==0.10.2
pdf2image==1.16.3
pdfminer.six==20221105
pdfplumber==0.10.2
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.5.0
pinecone-client==2.2.4
platformdirs==3.10.0
playwright==1.39.0
portalocker==2.8.2
posthog==3.0.2
preshed==3.0.9
prompt-toolkit==3.0.39
protobuf==4.24.3
psutil==5.9.5
ptyprocess==0.7.0
pulsar-client==3.3.0
pure-eval==0.2.2
pyarrow==13.0.0
pycocotools==2.0.7
pycparser==2.21
pydantic==1.10.12
pydantic_core==2.6.3
pydeck==0.8.0
pydub==0.25.1
pyee==11.0.1
Pygments==2.16.1
Pympler==1.0.1
pypandoc==1.11
pyparsing==3.1.1
pypdf==3.16.2
pypdfium2==4.20.0
PyPika==0.48.9
pytesseract==0.3.10
python-dateutil==2.8.2
python-docx==0.8.11
python-dotenv==1.0.0
python-iso639==2023.6.15
python-magic==0.4.27
python-multipart==0.0.6
python-pptx==0.6.21
pytube==11.0.2
pytz==2023.3.post1
pytz-deprecation-shim==0.1.0.post0
PyYAML==6.0.1
pyzmq==25.1.1
rapidfuzz==3.3.1
redis==5.0.0
referencing==0.30.2
regex==2023.8.8
requests==2.31.0
rich==13.5.2
rpds-py==0.10.2
safetensors==0.3.3
scikit-learn==1.3.1
scipy==1.11.3
sentence-transformers==2.2.2
sentencepiece==0.1.99
six==1.16.0
smart-open==6.4.0
smmap==5.0.0
sniffio==1.3.0
socksio==1.0.0
soupsieve==2.5
spacy==3.6.1
spacy-legacy==3.0.12
spacy-loggers==1.0.5
SQLAlchemy==2.0.22
sqlitedict==2.1.0
srsly==2.4.7
stack-data==0.6.2
starlette==0.27.0
streamlit
sympy==1.12
tabulate==0.9.0
tenacity==8.2.3
thinc==8.1.12
threadpoolctl==3.2.0
tiktoken==0.5.1
timm==0.9.7
tokenizers==0.14.0
toml==0.10.2
toolz==0.12.0
torch==2.0.1
torchvision==0.15.2
tornado==6.3.3
tqdm==4.66.1
traitlets==5.10.0
transformers==4.34.0
typer==0.9.0
typing-inspect==0.9.0
typing_extensions==4.7.1
tzdata==2023.3
tzlocal==4.3.1
ujson==5.8.0
unstructured==0.10.16
unstructured-inference==0.6.6
unstructured.pytesseract==0.3.12
urllib3==1.26.16
uvicorn==0.23.2
validators==0.22.0
wasabi==1.1.2
watchdog==3.0.0
watchfiles==0.20.0
wcwidth==0.2.6
websockets==11.0.3
wikipedia==1.4.0
xlrd==2.0.1
XlsxWriter==3.1.5
yarl==1.9.2
zipp==3.16.2

i have same problem sir here

import distutils.core
ModuleNotFoundError: No module named 'distutils'


[notice] A new release of pip is available: 24.0 -> 24.2
[notice] To update, run: pip install --upgrade pip
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[08:36:24] ❗️ installer returned a non-zero exit code
[08:36:24] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
[08:38:02] ❗️ Streamlit server consistently failed status checks
[08:38:02] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.

and i don’t know how to fix and when i’m delete my requirements.txt and then i try back to deploy the eror no module from sklearn.pipeline import Pipeline found. can someone assist me