[Fixed] Error while installing python package: llama-cpp-python – Python

by
Liam Thompson
llama-cpp-python python

Quick Fix: Install Desktop C++ with Visual Studio to properly install CMake. Check "Desktop development with C++" in the Visual Studio Installer. Consider installing the Windows 10 SDK as well. After this, run "pip install llama-cpp-python" to build the package.

The Problem:

I am trying to install the python package "llama-cpp-python" using pip, but I am getting an error during the installation. The error message mentions "subprocess-exited-with-error" and "CMAKE_C_COMPILER not set". I have tried various solutions, such as installing CMake, but none of them have worked. What is the cause of this error, and how can I successfully install the package?

The Solutions:

Solution 1: Install Desktop C++ Block with Visual Studio

To resolve the issue while installing the llama-cpp-python package, follow these steps:

  1. Open the Visual Studio Installer.
  2. Click on Modify.
  3. Check the Desktop development with C++ checkbox.
  4. Click on Modify to start the installation.

You can also install the Windows 10 SDK to ensure compatibility.

  1. After completing the installation, run the following command:

    pip install llama-cpp-python

This command should build successfully without any errors.

Solution 2: Install gcc and g++

The error message "CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage", "CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage" indicates that the gcc and g++ are not installed.

To install gcc and g++:

  • For Ubuntu:
sudo apt update
sudo apt upgrade
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-11 g++-11
  • For CentOS:
yum install scl-utils
yum install centos-release-scl
# find devtoolset-11
yum list all --enablerepo='centos-sclo-rh' | grep "devtoolset"

yum install -y devtoolset-11-toolchain
  • For Amazon Linux 2023:
sudo dnf install gcc
sudo dnf install g++

Q&A

What should be done to fix the ‘subprocess-exited-with-error’ error?

Install cmake and desktop c++ block with visual studio and Windows 10 SDK.

What might be the reason for the ‘CMAKE_C_COMPILER not set’ and ‘CMAKE_CXX_COMPILER not set’ errors?

gcc and g++ might not be installed or their version is too low.

Video Explanation:

The following video, titled "Failed building wheel for llama-cpp-python - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

I have been trying to install Oobabooga text generation webui on Linux both in CPU mode and GPU mode but still get this error about ...