`pip install` Gives Error on Some Packages
Asked Answered
Q

6

10

Some packages give errors when I try to install them using pip install. This is the error when I try to install chatterbot, but some other packages give this error as well:

pip install chatterbot
Collecting chatterbot
  Using cached ChatterBot-1.0.5-py2.py3-none-any.whl (67 kB)
Collecting pint>=0.8.1
  Downloading Pint-0.19.2.tar.gz (292 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 292.0/292.0 kB 1.6 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pyyaml<5.2,>=5.1
  Using cached PyYAML-5.1.2.tar.gz (265 kB)
  Preparing metadata (setup.py) ... done
Collecting spacy<2.2,>=2.1
  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
  ╰─> [35 lines of output]
      Collecting setuptools
        Using cached setuptools-65.0.1-py3-none-any.whl (1.2 MB)
      Collecting wheel<0.33.0,>0.32.0
        Using cached wheel-0.32.3-py2.py3-none-any.whl (21 kB)
      Collecting Cython
        Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
      Collecting cymem<2.1.0,>=2.0.2
        Using cached cymem-2.0.6-cp310-cp310-win_amd64.whl (36 kB)
      Collecting preshed<2.1.0,>=2.0.1
        Using cached preshed-2.0.1.tar.gz (113 kB)
        Preparing metadata (setup.py): started
        Preparing metadata (setup.py): finished with status 'error'
        error: subprocess-exited-with-error

        python setup.py egg_info did not run successfully.
        exit code: 1

        [6 lines of output]
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "C:\Users\oguls\AppData\Local\Temp\pip-install-qce7tdof\preshed_546a51fe26c74852ab50db073ad57f1f\setup.py", line 9, in <module>
            from distutils import ccompiler, msvccompiler
        ImportError: cannot import name 'msvccompiler' from 'distutils' (C:\Users\oguls\AppData\Local\Programs\Python\Python310\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: 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.

I don't specifically know which packages cause this error, a lot of them install without any problems.

I have tried updating pip, changing environment variables and other possible solutions I've found on the internet, but nothing seems to work.

Edit: The package I am trying to install supports my Python version.

Quinquefid answered 16/8, 2022 at 18:17 Comment(3)
There are many reasons why this error pops up. If the package your trying to install doesn't support your version of python, if you don't have the right dependencies if the package doesn't support your operating system, if there is a bug, if a dependency has been corrupted.....Lollop
as i have mentioned it's not an error specific to this package so the same thing happens with other packages that support my python version and my operating systemQuinquefid
Does the error message change when you first do pip install setuptools==65.0.1?Highclass
G
9

The real error in your case is:

ImportError: cannot import name 'msvccompiler' from 'distutils'

It occured because setuptools has broken distutils in version 65.0.0 (and has already fixed it in version 65.0.2). According to your log, the error occured in your global setuptools installation (see the path in error message), so you need to update it with the following command:

pip install -U setuptools

Those packages, however, may still not get installed or not work properly as the module causing this error doesn't support compiler versions needed for currently supported versions of Python.

Goahead answered 17/8, 2022 at 12:23 Comment(0)
O
1

From my experience, it's an issue with Python3.10. I went nuts with these errors and then tried both upgrade and downgrade. Works perfect with Python 3.11 or 3.8. (can't add a comment, hence...)

Overtone answered 15/3, 2023 at 16:46 Comment(4)
In the question and the accepted answer it was made clear that this is not a python version issue. It was already solved by updating setuptools.Kroon
@Kroon I tried setuptools too. It didn't resolve my issue. I only mentioned for those who couldn't resolve this issue with setuptools.Overtone
Thanks, this also solved my issue with these problems. Upgraded from Python version 3.10 to 3.12 and everything was fine again.Saccharo
After many tries, it worked to me. This is weird, I've performed the same command in 2 windows, one of them worked and the other only with Python 3.11Overage
U
0

I have had this issue when installing a venv. My solution was to edit my pip.ini by commenting on the target line (should look like this)

target = C:\PATHTOMYVENV\Lib\site-packages

Then I tried to pip install again and it worked. After that, the package is installed in the right location anyway.

Finally, I uncomment the target line (just in case).

Undrape answered 2/11, 2023 at 13:45 Comment(0)
M
0

I had this problem when using venv in PyCharm. I switched to conda and the problem went away.

Mcnulty answered 10/2, 2024 at 15:46 Comment(0)
H
0

Install the right version of cython. This worked for me

pip3 install cython==0.29.33

Holism answered 2/8, 2024 at 11:59 Comment(0)
S
-2

Same thing happened with me, it was basically pip's version problem. Try upgrading pip to latest version --22.3.1 and downgrade the python version from latest version --3.10.00 to 3.9.13...

pip --version check for pip's version

pip install notebook --upgrade -command to update pip to latest version

This worked for me

Scorpius answered 3/12, 2022 at 14:24 Comment(2)
What's the reason to downgrade Python here? Python 3.10 is supported by pip. Also note that your command will update the notebook package, not pip.Goahead
Is notebook mandatory?Puett

© 2022 - 2025 — McMap. All rights reserved.