Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.36k stars 2.39k forks source link

No module named 'distutils' on Python 3.12 #732

Open SyberiaK opened 8 months ago

SyberiaK commented 8 months ago

Steps to reproduce

  1. Install Python 3.12
  2. Install speech_recognition and pyaudio with pip (pip install SpeechRecognition and pip install pyaudio)
  3. Create a Python script with this code:
    
    import speech_recognition as sr

mic = sr.Microphone() print('hello')


4. Launch the script.

Expected behaviour
------------------

`hello` printed in the console

Actual behaviour
----------------

Because `distutils` was removed in Python 3.12, we get `ModuleNotFoundError: module named 'distutils'`

System information
------------------

My **Python version** is 3.12.
sapozhkov commented 7 months ago

try pip install setuptools

found on https://stackoverflow.com/questions/77931666/modulenotfounderror-no-module-named-distutils-how-to-solve-this-in-macos

Paulprojects8711 commented 6 months ago

try pip install setuptools

found on https://stackoverflow.com/questions/77931666/modulenotfounderror-no-module-named-distutils-how-to-solve-this-in-macos

i had the same issue and that actually fixed it thank you

ftnext commented 6 months ago

Thank you for reporting this issue, finding a solution, trying and sharing a result.

ref: https://docs.python.org/3/whatsnew/3.12.html#summary-release-highlights

gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.

I wonder adding pip install setuptools to README.

tphollis commented 4 months ago

I'm trying to use the pip install setuptools but I still get the error "ModuleNotFoundError: No module named 'distutils'". Actually, any time I try to use a pip command, that's the result. any ideas on how to get around this? I'm running on Ubuntu if that helps

donkrasnov commented 4 months ago

The same for me. I'm trying to do import undetected_chromedriver as uc but get an ModuleNotFoundError: No module named 'distutils'. I did pip install setuptools and get Requirement already satisfied:.... What I did wrong?

zahra566 commented 3 months ago

The same for me. I'm trying to do import undetected_chromedriver as uc but get an ModuleNotFoundError: No module named 'distutils'. I did pip install setuptools and get Requirement already satisfied:.... What I did wrong?

I had the same problem while using tensorflow, I added this: import setuptools.dist

marcorussi commented 3 months ago

Same problem, pip install setuptools is not enough.

rafa-mblm commented 3 months ago

For MAC and Homebrew use brew install python-setuptools

jasonlytehouse commented 3 months ago

Try pip install --upgrade setuptools Got it from here

shubhi commented 2 months ago

there is a '_disutils_hacks' file in the environmental site-packages, which will tell you to import setuptools before disutils is being used anywhere, which will definitely solve the issue.

RubTalha commented 2 months ago

https://stackoverflow.com/a/76691103/13086128

mxcxpx commented 1 month ago

hello - now with new Linux mint22 or ubuntu24 none of this will help .. and iam lost

pip install --upgrade setuptools error: externally-managed-environment

× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.

ltspicer commented 1 month ago

hello - now with new Linux mint22 or ubuntu24 none of this will help .. and iam lost

pip install --upgrade setuptools error: externally-managed-environment

× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.

How to Fix the pip externally-managed-environment error on Linux:

https://www.makeuseof.com/fix-pip-error-externally-managed-environment-linux/

Naateri commented 4 weeks ago

The same for me. I'm trying to do import undetected_chromedriver as uc but get an ModuleNotFoundError: No module named 'distutils'. I did pip install setuptools and get Requirement already satisfied:.... What I did wrong?

I had the same problem while using tensorflow, I added this: import setuptools.dist

This worked like a charm. Tried upgrading and reinstalling setuptools, but this did it.