Search code examples
pythonpip

Why do I get a subprocess error when installing cx_Freeze?


I am using the pip install cx_Freeze command, but I get a subprocess error. Why does it happen? Note: My system is Windows 11 and my Python version is 3.11.1. Command Output:

C:\Users\<user>\>pip install cx_Freeze
Collecting cx_Freeze
  Using cached cx_Freeze-6.13.1.tar.gz (1.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: packaging>=21.0 in c:\users\<user> \appdata\local\programs\python\python311\lib\site-packages (from cx_Freeze) (23.0)
Requirement already satisfied: setuptools<66,>=59.0.1 in c:\users\<user>\appdata\local\programs\python\python311\lib\site-packages (from cx_Freeze) (65.5.0)
Requirement already satisfied: lief>=0.12.0 in c:\users\<user>\appdata\local\programs\python\python311\lib\site-packages (from cx_Freeze) (0.12.3)
Building wheels for collected packages: cx_Freeze
  Building wheel for cx_Freeze (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cx_Freeze (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [84 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\cli.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\common.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\darwintools.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\dist.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\exception.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\executable.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\finder.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\freezer.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\module.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\parser.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\sandbox.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\setupwriter.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\winmsvcr.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\winversioninfo.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\_compat.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      copying cx_Freeze\__main__.py -> build\lib.win-amd64-cpython-311\cx_Freeze
      creating build\lib.win-amd64-cpython-311\cx_Freeze\bases
      copying cx_Freeze\bases\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\bases
      creating build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\bdist_mac.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\bdist_msi.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\bdist_rpm.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\build.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\build_exe.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\install.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\install_exe.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\_bdist_msi.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\_pydialog.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      copying cx_Freeze\command\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\command
      creating build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\crypto.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\cv2.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\exclude.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\numpy.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\scipy.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\_qthooks.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      copying cx_Freeze\hooks\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks
      creating build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      copying cx_Freeze\initscripts\console.py -> build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      copying cx_Freeze\initscripts\consolesetlibpath.py -> build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      copying cx_Freeze\initscripts\sharedlib.py -> build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      copying cx_Freeze\initscripts\sharedlibsource.py -> build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      copying cx_Freeze\initscripts\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      copying cx_Freeze\initscripts\__startup__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\initscripts
      creating build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt5
      copying cx_Freeze\hooks\pyqt5\add_library.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt5
      copying cx_Freeze\hooks\pyqt5\debug.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt5
      copying cx_Freeze\hooks\pyqt5\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt5
      creating build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt6
      copying cx_Freeze\hooks\pyqt6\debug.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt6
      copying cx_Freeze\hooks\pyqt6\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyqt6
      creating build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      copying cx_Freeze\hooks\pyside2\debug.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      copying cx_Freeze\hooks\pyside2\resource.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      copying cx_Freeze\hooks\pyside2\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      creating build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      copying cx_Freeze\hooks\pyside6\debug.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      copying cx_Freeze\hooks\pyside6\resource.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      copying cx_Freeze\hooks\pyside6\__init__.py -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      running egg_info
      writing cx_Freeze.egg-info\PKG-INFO
      writing dependency_links to cx_Freeze.egg-info\dependency_links.txt
      writing entry points to cx_Freeze.egg-info\entry_points.txt
      writing requirements to cx_Freeze.egg-info\requires.txt
      writing top-level names to cx_Freeze.egg-info\top_level.txt
      reading manifest file 'cx_Freeze.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'doc/src/license.rst'
      writing manifest file 'cx_Freeze.egg-info\SOURCES.txt'
      copying cx_Freeze\hooks\pyside2\qt.conf -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      copying cx_Freeze\hooks\pyside2\resource.qrc -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      copying cx_Freeze\hooks\pyside2\resource.sh -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside2
      copying cx_Freeze\hooks\pyside6\qt.conf -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      copying cx_Freeze\hooks\pyside6\resource.qrc -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      copying cx_Freeze\hooks\pyside6\resource.sh -> build\lib.win-amd64-cpython-311\cx_Freeze\hooks\pyside6
      running build_ext
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cx_Freeze
Failed to build cx_Freeze
ERROR: Could not build wheels for cx_Freeze, which is required to install pyproject.toml-based projects

Solution

  • From the error message: "error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/"

    cx_freeze requires a c-compiler: https://cx-freeze.readthedocs.io/en/latest/installation.html#python-requirements