Failed grpcio wheel for sumocr

Dear everybody, I’m trying to to follow the tutorial at https://commonroad.in.tum.de/tools/sumo-interface but I am stuck right in installation.

Basically, I’m getting errors regarding grpcio dependency, specifically a failure to build wheel for grpcio (I have the full log but apparently can’t upload text attachments).

This happens on macOS Big Sur version 11.7 (20G817) with Python 3.9.13, pip 22.2.2 and up to date setuptools and wheel packages.

Here follows log excerpt (I can’t paste whole text), will appreciate help.

...
Building wheels for collected packages: grpcio, ffmpeg
  Building wheel for grpcio (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [2173 lines of output]
...[several warnings]...
third_party/zlib/gzlib.c:252:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
              LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
              ^
      third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
      #  define LSEEK lseek
                      ^
      third_party/zlib/gzlib.c:252:9: note: did you mean 'fseek'?
      third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
      #  define LSEEK lseek
                      ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:162:6: note: 'fseek' declared here
      int      fseek(FILE *, long, int);
               ^
      third_party/zlib/gzlib.c:258:24: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
              state->start = LSEEK(state->fd, 0, SEEK_CUR);
                             ^
      third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
      #  define LSEEK lseek
                      ^
      third_party/zlib/gzlib.c:359:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
              ^
      third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
      #  define LSEEK lseek
                      ^
      third_party/zlib/gzlib.c:400:15: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
              ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
                    ^
      third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
      #  define LSEEK lseek
                      ^
      third_party/zlib/gzlib.c:496:14: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          offset = LSEEK(state->fd, 0, SEEK_CUR);
                   ^
      third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
      #  define LSEEK lseek
                      ^
      5 errors generated.
creating var
      creating var/folders
      creating var/folders/ld
      creating var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn
      creating var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T
      creating var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/tmp3givud8z
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c /var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/tmp3givud8z/a.c -o var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/tmp3givud8z/a.o
      Traceback (most recent call last):
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
          self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/_spawn_patch.py", line 54, in _commandfile_spawn
          _classic_spawn(self, command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
          spawn(cmd, dry_run=self.dry_run, **kwargs)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
          raise DistutilsExecError(
      distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/commands.py", line 260, in build_extensions
          build_ext.build_ext.build_extensions(self)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
          self._build_extensions_serial()
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
          self.build_extension(ext)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
          _build_ext.build_extension(self, ext)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
          objects = self.compiler.compile(
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
          self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/commands.py", line 243, in new_compile
          return old_compile(obj, src, ext, cc_args, extra_postargs,
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
          raise CompileError(msg)
      distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/setup.py", line 384, in <module>
          setuptools.setup(
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/commands.py", line 264, in build_extensions
          raise CommandError(
      commands.CommandError: Failed `build_ext` step:
      Traceback (most recent call last):
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
          self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/_spawn_patch.py", line 54, in _commandfile_spawn
          _classic_spawn(self, command)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
          spawn(cmd, dry_run=self.dry_run, **kwargs)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
          raise DistutilsExecError(
      distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/commands.py", line 260, in build_extensions
          build_ext.build_ext.build_extensions(self)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
          self._build_extensions_serial()
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
          self.build_extension(ext)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
          _build_ext.build_extension(self, ext)
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
          objects = self.compiler.compile(
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
          self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
        File "/private/var/folders/ld/lzdp_nln6z7d0y4rxbj9dggm0000gn/T/pip-install-2das2yzb/grpcio_10681a07bc354a34a8e2f238e6ecde32/src/python/grpcio/commands.py", line 243, in new_compile
          return old_compile(obj, src, ext, cc_args, extra_postargs,
        File "/Users/sm/PycharmProjects/RomoliGiacomo/romolienv/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
          raise CompileError(msg)
      distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for grpcio
  Running setup.py clean for grpcio
  Building wheel for ffmpeg (setup.py) ... done
  Created wheel for ffmpeg: filename=ffmpeg-1.4-py3-none-any.whl size=6083 sha256=f9c0d0946824855414d4dd7c0b6889fab8be8d86a0bfe26b8f9b49cc0eec787a
  Stored in directory: /Users/sm/Library/Caches/pip/wheels/1d/57/24/4eff6a03a9ea0e647568e8a5a0546cdf957e3cf005372c0245
Successfully built ffmpeg
Failed to build grpcio
Installing collected packages: wcwidth, sumolib, pure-eval, ptyprocess, pickleshare, ffmpeg, executing, backcall, appnope, websocket-client, urllib3, traitlets, traci, pygments, prompt-toolkit, pexpect, parso, idna, grpcio, decorator, charset-normalizer, certifi, asttokens, stack-data, requests, matplotlib-inline, libsumo, jedi, ipython, docker, sumocr
  Running setup.py install for grpcio ... \
 
  [and here it basically re-tries to install grpcio, getting another round of the same errors....dunno why]

Unfortunately, this is a problem related to a third-party library on macOS.
Therefore, we can only provide limited support for this specific problem.

Maybe the solution here helps.
If not, maybe another solution on stackoverflow or in the issues or discussions of the grpcio github repository helps.

Thx for the reply, I hope it happened to others before.
Nevermind, will try to figure it out.

If you find a solution, please post it also here in the forum.

@smariani Please try Python 3.7. Maybe this works.

Dear @sebastian.maierhofer , sorry for the very late reply.

I’ve finally managed to fix the issue, hence I came back here to post the solution that worked for me in case anyone else stumbles upon the same problem

Log inspection traces error back to error
third_party/zlib/gzlib.c:252:9: error: implicit declaration of function 'lseek' is invalid in C99

	Solved by:

		i) `python3 -m pip install --upgrade pip`
		ii) `python3 -m pip install --upgrade setuptools`
		iii) `python3 -m pip install --upgrade wheel`
		iv) `export CFLAGS="$CFLAGS -DHAVE_UNISTD_H"` from [https://github.com/grpc/grpc/issues/25060#issuecomment-755538155](https://github.com/grpc/grpc/issues/25060#issuecomment-755538155)

Then just re-issue the original pip install command

Hope it helps somebody sooner or later :smiley:

1 Like