Not install pip install commonroad-drivability-checker (MAC OS)


RuntimeError: CMake must be installed to build the following extensions: commonroad_dc
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for commonroad-drivability-checker
Running setup.py clean for commonroad-drivability-checker
Building wheel for polygon3 (setup.py) … error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
Using NumPy extension!
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-cpython-311
creating build/lib.macosx-10.9-x86_64-cpython-311/Polygon
copying Polygon/Shapes.py → build/lib.macosx-10.9-x86_64-cpython-311/Polygon
copying Polygon/IO.py → build/lib.macosx-10.9-x86_64-cpython-311/Polygon
copying Polygon/init.py → build/lib.macosx-10.9-x86_64-cpython-311/Polygon
copying Polygon/Utils.py → build/lib.macosx-10.9-x86_64-cpython-311/Polygon
running build_ext
building ‘Polygon.cPolygon’ extension
creating build/temp.macosx-10.9-x86_64-cpython-311
creating build/temp.macosx-10.9-x86_64-cpython-311/src
clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/lionel.messi.kun/anaconda3/include -fPIC -O2 -isystem /Users/lionel.messi.kun/anaconda3/include -DDEFAULT_STYLE=STYLE_LIST -DWITH_NUMPY=1 -Isrc -I/Users/lionel.messi.kun/anaconda3/lib/python3.11/site-packages/numpy/core/include -I/Users/lionel.messi.kun/anaconda3/include/python3.11 -c src/PolyUtil.c -o build/temp.macosx-10.9-x86_64-cpython-311/src/PolyUtil.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command ‘/usr/bin/clang’ 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 polygon3
Running setup.py clean for polygon3
Failed to build commonroad-drivability-checker polygon3
ERROR: Could not build wheels for commonroad-drivability-checker, polygon3, which is required to install pyproject.toml-based projects
(base) lionel.messi.kun@r143087150 commonroad-search % pip install pyproject.toml-based projects
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement pyproject.toml-based (from versions: none)
ERROR: No matching distribution found for pyproject.toml-based

  1. Your python version is too new. MacOS binaries are available for python 3.7 - 3.9.
    The version that has built MacOS binaries is:
    pip install commonroad-drivability-checker==2022.2.1

    The newest version of drivability checker (2023.1) can be installed on linux without manual compilation.

  2. You should make sure you are using Anaconda 64 bit and not the Anaconda version for the M1 CPU.

  3. Try running pip install Polygon3 before installing the drivability checker. It requires XCode to be installed. Try reinstalling XCode, there seems to be a problem with your XCode installation.

Hello, I am facing the same issue on MacOS. I am using Anaconda 64bit, the Python version of my virtual environment is 3.9.18 and I freshly installed XCode.

  1. pip install commonroad-drivability-checker==2022.2.1 results in the same error that was mentioned by leomessikum.
  2. As mentioned, I am using the correct conda version. I also checked that pip of the virtual environment is being used.
  3. pip install polygon3 fails with the error message Could not build wheels for polygon3, lxml, which is required to install pyproject.toml-based projects.

Thus, I think that it all boils down to polygon3 which cannot be installed. I cannot find any occurrence of this error online. pip install wheel as described on StackOverflow did not resolve the issues. Any other ideas?

Edit: I was able to resolve the error above using xcode-select --install. Apparently, XCode is not the only requirement but in particular the command line tools. Once you have done this, you have to execute pip install lxml, followed by pip install polygon3. Once you have done this, you get an error that cmake has to be installed, so you have to execute pip install cmake.

After this, there appears another error:

Building wheels for collected packages: commonroad-drivability-checker
  Building wheel for commonroad-drivability-checker (setup.py) ... error
  error: subprocess-exited-with-error
Click to expand whole error message
CMake Generate step failed.  Build files cannot be regenerated correctly.
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/v0/7nn3mz5n3t7096mb_ygnm5yw0000gn/T/pip-install-dp6ljl_c/commonroad-drivability-checker_7ec21fb1f9684ff08c1fcb3dc3272458/setup.py", line 178, in <module>
          setup(
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 364, in run
          self.run_command("build")
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 131, in run
          self.run_command(cmd_name)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/v0/7nn3mz5n3t7096mb_ygnm5yw0000gn/T/pip-install-dp6ljl_c/commonroad-drivability-checker_7ec21fb1f9684ff08c1fcb3dc3272458/setup.py", line 44, in run
          self.build_extension(ext)
        File "/private/var/folders/v0/7nn3mz5n3t7096mb_ygnm5yw0000gn/T/pip-install-dp6ljl_c/commonroad-drivability-checker_7ec21fb1f9684ff08c1fcb3dc3272458/setup.py", line 139, in build_extension
          subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=build_dir)
        File "/Users/username/opt/anaconda3/envs/commonroad-py39/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)

subprocess.CalledProcessError: Command '['cmake', '/private/var/folders/v0/7nn3mz5n3t7096mb_ygnm5yw0000gn/T/pip-install-dp6ljl_c/commonroad-drivability-checker_7ec21fb1f9684ff08c1fcb3dc3272458',
'-DPYTHON_INCLUDE_DIR=/Users/username/opt/anaconda3/envs/commonroad-py39/include/python3.9',
'-DPYTHON_LIBRARY=',
'-DPYTHON_EXECUTABLE=/Users/username/opt/anaconda3/envs/commonroad-py39/bin/python',
'-DBUILD_DOC=OFF',
'-DADD_TESTS=OFF',
'-DADD_TRIANGLE=OFF',
'-DADD_PYTHON_BINDINGS=ON',
'-DCMAKE_BUILD_TYPE=Release',
'-DCMAKE_INSTALL_PREFIX:PATH=/private/var/folders/v0/7nn3mz5n3t7096mb_ygnm5yw0000gn/T/pip-install-dp6ljl_c/commonroad-drivability-checker_7ec21fb1f9684ff08c1fcb3dc3272458/build/temp.macosx-10.9-x86_64-cpython-39/dist']'
returned non-zero exit status 1.

This error can then be fixed by explicitly choosing the version vitrus mentioned:
pip install commonroad-drivability-checker==2022.2.1

For me, this install finally worked. I think that the dependency tree for MacOS needs some fixes by code maintainers…

To summarize,

xcode-select --install
brew install cmake
conda create -n commonroad python=3.7
pip install lxml
pip install Polygon3
pip install commonroad-drivability-checker==2022.2.1

may lead to a successful installation. I don’t have a Mac computer to check it at the moment. As far as I remember, batch processing module of commonroad-search required python=3.7 some time ago. Drivability checker requires python 3.7-3.9 on Mac computers to be installed with a binary python wheel (and not compiled manually). It is also possible to install drivability checker on MacOS computers with M1 CPU in this way.