getting "ModuleNotFoundError: No module named 'distutils'" when trying to run my code

1.4k views Asked by At

I made a Selenium bot on my local Mac, where it works flawlessly. When trying to run it on a virtual Windows 10 machine via google cloud, I'm getting these errors:

"Traceback (most recent call last):
  File "c:\Users\ahamed_a_1235\instabot.py", line 1, in <module>
    import undetected_chromedriver as uc
  File "C:\Users\ahamed_a_1235\AppData\Local\Programs\Python\Python312\Lib\site-
packages\undetected_chromedriver\__init__.py", line 44, in <module>
    from .patcher import IS_POSIX
  File "C:\Users\ahamed_a_1235\AppData\Local\Programs\Python\Python312\Lib\site-
packages\undetected_chromedriver\patcher.py", line 4, in <module>
    from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
PS C:\Users\ahamed_a_1235>"

Please help. Here are screenshots with related details:

enter image description here

enter image description here

I tried installing the libraries again, but still have the issue.

3

There are 3 answers

3
yusuf On
  • Have you checked if Python development libraries are installed?
python -m ensurepip --upgrade
  • After this is done, you can install undetected-chromium like so:
pip install undetected-chromedriver
  • I can also see that you are using Python 3.12. The entire distutils package is deprecated in this Python version. Refer this
0
SSujitXX On

Just upgrade, it helped to solve this issue

pip install --upgrade setuptools
0
ismail grira On
  • Install an older python version

or

  • use some other package to replace undetected-chromedriver

distutils package is removed from python 3.12 and undetected-chromedriver uses this package to get LooseVersion

undetected-chromedriver package needs to get updated soon