Unable to install grpcio using pip install grpcio
Asked Answered
C

7

79

I am getting error while installing grpcio using pip install grpcio on my windows machine.I read here - https://github.com/grpc/grpc/issues/17829 that it may be due to error in a version of setuptools. I upgraded my setuptools to the latest version i.e. 41.0.1 . Still getting the same build error. Its not happening for any other package. I have tried reinstalling pip and python both on my laptop. I'm attaching my error

Building wheels for collected packages: grpcio
Building wheel for grpcio (setup.py) ... error
ERROR: Complete output from command 'c:\python27\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'c:\\users\\s\\appdata\\local\\temp\\pip-install-ge5zhq\\grpcio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel
-d 'c:\users\s\appdata\local\temp\pip-wheel-txjhlh' --python-tag cp27:
  ERROR: Found cython-generated files...
  running bdist_wheel
  running build
  running build_py
  running build_project_metadata
  creating python_build
  creating python_build\lib.win-amd64-2.7
  creating python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_auth.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_channel.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_common.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_compression.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_grpcio_metadata.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_interceptor.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_plugin_wrapping.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_server.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\_utilities.py -> python_build\lib.win-amd64-2.7\grpc
  copying src\python\grpcio\grpc\__init__.py -> python_build\lib.win-amd64-2.7\grpc
  creating python_build\lib.win-amd64-2.7\grpc\beta
  copying src\python\grpcio\grpc\beta\implementations.py -> python_build\lib.win-amd64-2.7\grpc\beta
  copying src\python\grpcio\grpc\beta\interfaces.py -> python_build\lib.win-amd64-2.7\grpc\beta
  copying src\python\grpcio\grpc\beta\utilities.py -> python_build\lib.win-amd64-2.7\grpc\beta
  copying src\python\grpcio\grpc\beta\_client_adaptations.py -> python_build\lib.win-amd64-2.7\grpc\beta
      copying src\python\grpcio\grpc\beta\_metadata.py -> python_build\lib.win-amd64-2.7\grpc\beta
      copying src\python\grpcio\grpc\beta\_server_adaptations.py -> python_build\lib.win-amd64-2.7\grpc\beta
      copying src\python\grpcio\grpc\beta\__init__.py -> python_build\lib.win-amd64-2.7\grpc\beta
      creating python_build\lib.win-amd64-2.7\grpc\experimental
      copying src\python\grpcio\grpc\experimental\gevent.py -> python_build\lib.win-amd64-2.7\grpc\experimental
      copying src\python\grpcio\grpc\experimental\session_cache.py -> python_build\lib.win-amd64-2.7\grpc\experimental
      copying src\python\grpcio\grpc\experimental\__init__.py -> python_build\lib.win-amd64-2.7\grpc\experimental
      creating python_build\lib.win-amd64-2.7\grpc\framework
      copying src\python\grpcio\grpc\frame`enter code here`work\__init__.py -> python_build\lib.win-amd64-2.7\grpc\framework
      creating python_build\lib.win-amd64-2.7\grpc\_cython
      copying src\python\grpcio\grpc\_cython\__init__.py -> python_build\lib.win-amd64-2.7\grpc\_cython
      creating python_build\lib.win-amd64-2.7\grpc\framework\common
      copying src\python\grpcio\grpc\framework\common\cardinality.py -> python_build\lib.win-amd64-2.7\grpc\framework\common
      copying src\python\grpcio\grpc\framework\common\style.py -> python_build\lib.win-amd64-2.7\grpc\framework\common
      copying src\python\grpcio\grpc\framework\common\__init__.py -> python_build\lib.win-amd64-2.7\grpc\framework\common
      creating python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\abandonment.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\callable_util.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\future.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\logging_pool.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\stream.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\stream_util.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      copying src\python\grpcio\grpc\framework\foundation\__init__.py -> python_build\lib.win-amd64-2.7\grpc\framework\foundation
      creating python_build\lib.win-amd64-2.7\grpc\framework\interfaces
      copying src\python\grpcio\grpc\framework\interfaces\__init__.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces
      creating python_build\lib.win-amd64-2.7\grpc\framework\interfaces\base
      copying src\python\grpcio\grpc\framework\interfaces\base\base.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces\base
      copying src\python\grpcio\grpc\framework\interfaces\base\utilities.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces\base
      copying src\python\grpcio\grpc\framework\interfaces\base\__init__.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces\base
      creating python_build\lib.win-amd64-2.7\grpc\framework\interfaces\face
      copying src\python\grpcio\grpc\framework\interfaces\face\face.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces\face
      copying src\python\grpcio\grpc\framework\interfaces\face\utilities.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces\face
      copying src\python\grpcio\grpc\framework\interfaces\face\__init__.py -> python_build\lib.win-amd64-2.7\grpc\framework\interfaces\face
      creating python_build\lib.win-amd64-2.7\grpc\_cython\_cygrpc
      copying src\python\grpcio\grpc\_cython\_cygrpc\__init__.py -> python_build\lib.win-amd64-2.7\grpc\_cython\_cygrpc
      creating python_build\lib.win-amd64-2.7\grpc\_cython\_credentials
      copying src\python\grpcio\grpc\_cython\_credentials\roots.pem -> python_build\lib.win-amd64-2.7\grpc\_cython\_credentials
      running build_ext
      error: [Error 2] The system cannot find the file specified
      ----------------------------------------
      ERROR: Failed building wheel for grpcio
      Running setup.py clean for grpcio
    Failed to build grpcio
Coot answered 29/5, 2019 at 9:54 Comment(5)
if i specify the version to grpcio==1.20.0 , it is installing . for 1.21.1 it is notCoot
Can you provide more information about your platform? The problem you are encountering is different from issue 17829.You will find better support submitting this bug as GitHub issue github.com/grpc/grpc.Boser
Also, if you are using Cygwin, unfortunately, we don't support it...Boser
this issue has been discussed here - github.com/grpc/grpc/issues/20831.. it seems pip has issues with the latest version of python (3.8 as of now; i m using Windows 64 version)Regelation
Could this be related to this: github.com/rust-lang/rustup/issues/3342 ?Cahoon
L
196

First, upgrade pip

pip3 install --upgrade pip

Then, update the setup tools:

python3 -m pip install --upgrade setuptools

At last, install grpcio using :

pip3 install --no-cache-dir  --force-reinstall -Iv grpcio==<version_number>
Lublin answered 21/6, 2020 at 15:49 Comment(4)
After hours of trying to install this on a Raspberry Pi and getting hung up on this package, I thank you. Took 2 minutes for everything after that.Jonell
For those who arrive here with Mac's running M1: the above solution doesn't work, but this one does: #66641205Elwoodelwyn
This worked for me and resolved a different issue on Ubuntu 18.04 x86. It kept attempting and failing to build grpcio from source (which takes 10+ minutes); once I upgraded pip and setuptools, it just found the wheel and succeeded quickly. Thanks!Duckboard
For me, the only solution was to install wheels pre-compiled for Arm: https://mcmap.net/q/262920/-how-can-i-install-grpcio-on-an-apple-m1-silicon-laptopBahrain
D
11

try to install using

grpcio==1.36.1

it worked in my case.

Dysphasia answered 29/3, 2021 at 17:16 Comment(1)
nice! this worked, just bumping the version in my requirements.txt fixed it, thanks!Wineshop
A
5

just use python3.9

no EXPORT xx=xx stuff

works in macos m1

Anode answered 4/8, 2022 at 23:7 Comment(2)
Hi mefegni, welcome to Stackoverflow. Please expand your answer to explain how to apply it.Tailrace
Python3.9 worked for me too. The other solutions unfortunately didn't work. But I also can't explain why.Mutt
E
2

I ran into same issue using python 3.7 with setuptools is 41.0.1 while installing package that includes building wheel for gracio ... Building wheel for grpcio (setup.py) ... error

warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
src/python/Gracie/grpc/_cython/cygrpc.cpp:1343:14: fatal error: 'cstdlib' file not found
    #include <cstdlib>
             ^~~~~~~~~
1 warning and 1 error generated.

Could NOT find a way to resolve above, but I tried with another environment with Python 3.6.x with same setuptools 41.0.1. Somehow "setup" found the prebuilt wheel for gracio (i.e. grpcio==1.11.0), and got through setup.

Exequatur answered 2/8, 2019 at 17:36 Comment(0)
D
0

this worked for me on MacOS using VScode: xcode-select --install

Dominoes answered 15/7, 2023 at 17:54 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Whisper
K
0

Summary - Using previous released version [over latest version] of python worked for me.

Details -

I was getting below error when I used

FROM python:3

in dockerfile. Note that python 3.12 is released just 2 days ago and after that this started failing with below error -

 ERROR: Could not build wheels for grpcio, grpcio-tools, which is required to install pyproject.toml-based projects

I changed dockerfile to use last release version of python as below -

FROM python:3.11
Keenan answered 4/10, 2023 at 11:35 Comment(0)
R
0

First check https://pypi.org/project/grpcio/ for latest version number. Then in your requirements.txt try to change version to latest: grpcio==1.59.0 or grpcio==<latest_version_here>

Then run:

pip3 install -r requirements.txt

It's working for my case.

Randers answered 9/10, 2023 at 6:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.