Chatterbot is not installing

So, to give you a idea of the problem, I want to create AI with python. So I wanted to install chatterbot to help me create AI with Python. Now, when I go installing chatterbot, I get this error message:

 "Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [114 lines of output]
      Collecting setuptools
        Using cached setuptools-69.5.1-py3-none-any.whl.metadata (6.2 kB)
      Collecting wheel<0.33.0,>0.32.0
        Using cached wheel-0.32.3-py2.py3-none-any.whl.metadata (2.1 kB)
      Collecting Cython
        Using cached Cython-3.0.10-cp312-cp312-win_amd64.whl.metadata (3.2 kB)
      Collecting cymem<2.1.0,>=2.0.2
        Using cached cymem-2.0.8-cp312-cp312-win_amd64.whl.metadata (8.6 kB)
      Collecting preshed<2.1.0,>=2.0.1
        Using cached preshed-2.0.1.tar.gz (113 kB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started       
        Getting requirements to build wheel: finished with status 'done'
        Installing backend dependencies: started
        Installing backend dependencies: finished with status 'done'
        Preparing metadata (pyproject.toml): started       
        Preparing metadata (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        Preparing metadata (pyproject.toml) did not run successfully.
        exit code: 1

        [79 lines of output]
        running dist_info
        creating C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info      
        writing C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\PKG-INFO
        writing dependency_links to C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\dependency_links.txt
        writing requirements to C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\requires.txt
        writing top-level names to C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\top_level.txt
        writing manifest file 'C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\SOURCES.txt'
        reading manifest file 'C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\SOURCES.txt'
        reading manifest template ''
        adding license file 'LICENSE'
        writing manifest file 'C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed.egg-info\SOURCES.txt'
        creating 'C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-modern-metadata-63ny29ze\preshed-2.0.1.dist-info'
        Traceback (most recent call last):
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\normal\Lib\site-packages\wheel\", line 10, in <module>
            from importlib.machinery import get_all_suffixes
        ImportError: cannot import name 'get_all_suffixes' from 'importlib.machinery' (C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Programs\Python\Python312\Lib\importlib\ Did you mean: 'all_suffixes'?

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\", line 353, in <module>
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\", line 335, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\", line 149, in prepare_metadata_for_build_wheel
            return hook(metadata_directory, config_settings)
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\", line 366, in prepare_metadata_for_build_wheel
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\", line 487, in run_setup
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\", line 311, in run_setup
            exec(code, locals())
          File "<string>", line 149, in <module>
          File "<string>", line 114, in setup_package      
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\", line 104, in setup
            return distutils.core.setup(**attrs)
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\_distutils\", line 184, in setup
            return run_commands(dist)
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\_distutils\", line 200, in run_commands     
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\_distutils\", line 969, in run_commands     
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\", line 967, in run_command
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\_distutils\", line 988, in run_command      
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\command\", line 97, in run
            bdist_wheel = self.get_finalized_command('bdist_wheel')
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\_distutils\", line 302, in get_finalized_command
            cmd_obj = self.distribution.get_command_obj(command, create)
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\_distutils\", line 861, in get_command_obj  
            klass = self.get_command_class(command)        
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\overlay\Lib\site-packages\setuptools\", line 714, in get_command_class
            self.cmdclass[command] = cmdclass = ep.load()  
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Programs\Python\Python312\Lib\importlib\metadata\", line 205, in load
            module = import_module('module'))  
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Programs\Python\Python312\Lib\importlib\", line 90, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
          File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
          File "<frozen importlib._bootstrap_external>", line 995, in exec_module
          File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\normal\Lib\site-packages\wheel\", line 21, in <module>
            from .pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag, get_platform
          File "C:\Users\rayan.RAYANFAMILYCOMP\AppData\Local\Temp\pip-build-env-0u0x5mo6\normal\Lib\site-packages\wheel\", line 12, in <module>
            from imp import get_suffixes as get_all_suffixes
        ModuleNotFoundError: No module named 'imp'
        [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed

      Encountered error while generating package metadata. 

      See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip."

Can you please help me fix this?

Chatterbot has not been maintained since 2020, and its PyPI listing says very clearly that it will not support any version of Python more recent than 3.8.

In particular, the version of wheel that it wants to use (Collecting wheel<0.33.0,>0.32.0; Using cached wheel-0.32.3-py2.py3-none-any.whl.metadata (2.1 kB)) is quite old (from 2018). It wants to use the imp standard library module, but this has been removed in Python 3.12.

Please try to use a supported version of Python - of these, only 3.8 is currently maintained, and only for a few more months. Better yet, try to find a different library for your task.

1 Like

Is there any other modules that I can use?

So not all modules check for the Python version that the path points to and give an error message if it’s an unsupported Python version?

Because I came across this error when installing Chatterbot from a tutorial as well. And the tutorial I saw didn’t mention which Python versions to use even though I only search for tutorials created in the past 12 months.

In fact, hardly any of them do. The only real way to make that work for sure is to reject every Python version that doesn’t exist yet when you release the code - but that is far too conservative and leads to a lot of complaints from users.

But more importantly, the problem here occurs during installation. Even adding a check to might be too late - because when Pip builds a wheel, it has to do other things (set up a build environment with build-time dependencies) before it can pay any attention to your code. In fact, the does have such a check, which apparently even worked for 3.9 through 3.11 - but is now broken in 3.12.

In this case, the problem occurs because the requested version of wheel - a build-time dependency - isn’t compatible with the Python 3.12 standard library. I can’t actually tell where that dependency is being requested, since it isn’t direct. But in order for Python 3.12 to be rejected properly, that would have to happen in pyproject.toml - which the project doesn’t use.

Keep in mind that there hasn’t been a release of the project since mid-2020 - there have been packaging-related PEPs since then, and using pyproject.toml at all was much less common at that point, as it was not yet seen as necessary, and people always grumble about having to change these kinds of things. (But it really is a change for the better. Python should not have to run code in order to find out whether or not it should try to prepare other code for running, or what dependencies are needed to do so.)

Because it’s seen as so important not to break backwards compatibility, Pip will happily try to install things that are obscenely out of date. It will even try to install packages that are 2.x-only code on 3.12 - as long as the package doesn’t explicitly try to prevent that by itself. It can even end up bailing out with a SyntaxError from the file, because the file is not 3.x-compatible Python syntax (e.g., it might use a print statement for a diagnostic, or mix spaces and tabs in a way that 3.x doesn’t accept but 2.x does) but there was nothing else to prevent the process from getting that far. And it was not reasonable to expect people who developed packages for, say, Python 2.5 to predict that there would be a future Python 3 that would break their that way, or that future packaging would involve alternatives to