Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Fails: cannot import name 'msvccompiler' from 'distutils #2384

Open
JeffZurita opened this issue Nov 21, 2024 · 2 comments
Open
Assignees

Comments

@JeffZurita
Copy link

pip install chatterbot
Collecting chatterbot
Using cached ChatterBot-1.0.5-py2.py3-none-any.whl.metadata (8.1 kB)
Collecting mathparse<0.2,>=0.1 (from chatterbot)
Using cached mathparse-0.1.2-py3-none-any.whl.metadata (776 bytes)
Collecting nltk<4.0,>=3.2 (from chatterbot)
Using cached nltk-3.9.1-py3-none-any.whl.metadata (2.9 kB)
Collecting pint>=0.8.1 (from chatterbot)
Using cached Pint-0.24.4-py3-none-any.whl.metadata (8.5 kB)
Collecting pymongo<4.0,>=3.3 (from chatterbot)
Using cached pymongo-3.13.0-cp311-cp311-win_amd64.whl.metadata (9.8 kB)
Collecting python-dateutil<2.8,>=2.7 (from chatterbot)
Using cached python_dateutil-2.7.5-py2.py3-none-any.whl.metadata (7.5 kB)
Collecting pyyaml<5.2,>=5.1 (from chatterbot)
Using cached PyYAML-5.1.2.tar.gz (265 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting spacy<2.2,>=2.1 (from chatterbot)
Using cached spacy-2.1.9.tar.gz (30.7 MB)
Installing build dependencies ... error
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [51 lines of output]
Collecting setuptools
Using cached setuptools-75.6.0-py3-none-any.whl.metadata (6.7 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.11-cp311-cp311-win_amd64.whl.metadata (3.2 kB)
Collecting cymem<2.1.0,>=2.0.2
Using cached cymem-2.0.8-cp311-cp311-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 'error'
error: subprocess-exited-with-error

    Getting requirements to build wheel did not run successfully.
    exit code: 1

    [20 lines of output]
    Traceback (most recent call last):
      File "C:\Users\Primus\Documents\Python Scripts\Chatterbot_venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
        main()
      File "C:\Users\Primus\Documents\Python Scripts\Chatterbot_venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Primus\Documents\Python Scripts\Chatterbot_venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
        return hook(config_settings)
               ^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Primus\AppData\Local\Temp\pip-build-env-gjleqymb\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
        return self._get_build_requires(config_settings, requirements=[])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Primus\AppData\Local\Temp\pip-build-env-gjleqymb\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
        self.run_setup()
      File "C:\Users\Primus\AppData\Local\Temp\pip-build-env-gjleqymb\overlay\Lib\site-packages\setuptools\build_meta.py", line 522, in run_setup
        super().run_setup(setup_script=setup_script)
      File "C:\Users\Primus\AppData\Local\Temp\pip-build-env-gjleqymb\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
        exec(code, locals())
      File "<string>", line 9, in <module>
    ImportError: cannot import name 'msvccompiler' from 'distutils' (C:\Users\Primus\AppData\Local\Temp\pip-build-env-gjleqymb\overlay\Lib\site-packages\setuptools\_distutils\__init__.py)
    [end of output]

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

  Getting requirements to build wheel 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.
  [end of output]

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

@gunthercox
Copy link
Owner

This error might be related to importlib_metadata, specifically it needing to be pinned less than version 5 (importlib_metadata<5). I'll see if I can find a way to consistently recreate the issue and pin that requirement if that is in fact the case.

@gunthercox gunthercox self-assigned this Jan 5, 2025
@nballenger
Copy link

nballenger commented Jan 8, 2025

Edit: I may have spoken too confidently. Even making allowances for the version issues, I'm still running into installation failures with spacy, particulary its blis dependency not wanting to build. I'll try again later if I have time, but maybe some of this is still of interest.


Hi, @gunthercox! I'm evaluating the package for an experiment, and I also ran into some of the install issues. I think what's going on is that because you don't have a pyproject.toml, the PyPI-based install via pip isn't fully/properly aware that you're using setuptools as your build backend. As a result it isn't enforcing ChatterBot's version restrictions (because it doesn't know where to find them until it tries to build the wheels), and the whole thing is tipping over when it needs things that have been removed from setuptools / distutils in Python versions after 3.8.

Annoyingly, you won't encounter the problem if you attempt a local, source-based install following a git clone of the project, because doing pip install ./ChatterBot will look at setup.py in time to squawk about version discrepancies--it will only fail for the network install since that really wants a pyproject.toml metadata file to be present in the project root.

I think the simplest fix is just to add a minimal pyproject.toml file, as per "Is pyproject.toml mandatory?" in the Python Packaging guide. That should be enough of a signpost for a network-based pip install to know that it needs to obey what's in your setup.py, since it will correctly identify setuptools as your chosen build backend.

For simplicity's sake, here's that minimal pyproject.toml:

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

You may also want to make one additional change in setup.py itself, depending on how you meant to restrict the Python versions the project may be installed under. Currently you have your Python version restriction as:

python_requires='>=3.4, <=3.8',

That version spec string will, I believe, restrict to any Python from 3.4.0 on the low end, to 3.8.0 on the high end--so it includes the <major>.<minor> for 3.8, but won't pick up the .<micro> patch versions that culminated in 3.8.20. If you'd like to allow installs for any release of 3.8, you can change your upper bound specifier in one of two ways:

  1. Use the compatible release clause, ~=, as in ~= 3.8, which will target any 3.8.* release
  2. Stick with the inclusive ordered clause, <=, but explicitly set it to <= 3.8.20, since that was the final release for the 3.8 version that's now in EOL status (so unlikely to receive additional releases)

Thanks for putting up the package and maintaining it, I know it's a ton of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants