private-gpt icon indicating copy to clipboard operation
private-gpt copied to clipboard

ERROR: Could not build wheels for llama-cpp-python, hnswlib, lxml, which is required to install pyproject.toml-based project

Open mkam0012 opened this issue 1 year ago • 22 comments

I am trying to install the requirements on an Apple M1 Pro in a Macbook Pro and getting errors for building three wheels, have absolutely no idea how to fix

mkam0012 avatar May 24 '23 08:05 mkam0012

Screenshot 2023-05-24 at 6 41 56 pm

mkam0012 avatar May 24 '23 08:05 mkam0012

I'm also facing the face issue ( I tried with Ubuntu and Cent OS - both failed with the same error),

Angurajdin avatar May 24 '23 10:05 Angurajdin

download and install the "Microsoft C++ Build Tools" from the official Visual Studio website. Here are the steps you can take:

Visit the following URL: https://visualstudio.microsoft.com/visual-cpp-build-tools/.

On the webpage, you should see a "Download" button for the Visual Studio Build Tools. Click on it to initiate the download.

Once the download is complete, run the installer and follow the instructions to install the Microsoft C++ Build Tools.

During the installation process, make sure to select the necessary components for C++ development. This typically includes selecting the "C++ build tools" and any required packages or libraries.

After the installation is complete, try installing the hnswlib package again using pip.

jackfood avatar May 24 '23 13:05 jackfood

I'm also facing the face issue ( I tried with CentOS 7.6 - both failed with the same error) image

zhaolong1990ok avatar May 24 '23 13:05 zhaolong1990ok

Also if using Llama GGLM, if langchain required, use 'pip install langchain[all]' to install all modules.

jackfood avatar May 24 '23 13:05 jackfood

image i installed Microsoft C++ Build Tools with "C++ build tools" as u mentioned but still getting this error

abdulfarhandevil avatar May 24 '23 14:05 abdulfarhandevil

Thanks @jackfood,I was able to install it on Windows (after using the Microsoft C++ Build Tools), but how do I do the same on Linux (Ubuntu, CentOS, or any other Linux environment) since we can not use the Microsoft C++ Build Tools in Linux?

Angurajdin avatar May 24 '23 14:05 Angurajdin

@abdulfarhandevil, Please share a screenshot of the Microsoft C++ Build Tools components that you installed

Angurajdin avatar May 24 '23 14:05 Angurajdin

image The red marked are the Microsoft C++ Build Tools components that i have installed @Angurajdin Can u pls check if i missed anything or if its correct what should i do further to fix this issue

abdulfarhandevil avatar May 24 '23 15:05 abdulfarhandevil

@abdulfarhandevil you can download the build tools from here - https://visualstudio.microsoft.com/visual-cpp-build-tools/

taran11313 avatar May 24 '23 18:05 taran11313

I have found the solution for this problem -

  1. First install visual cpp build tools from this link - https://visualstudio.microsoft.com/visual-cpp-build-tools/
  2. Then install cython using the below command - py -m pip install cython
  3. Set the following path in your PATH variable - C:\Users\XXXXX\AppData\Local\Programs\Python\Python311\Scripts

taran11313 avatar May 24 '23 20:05 taran11313

Its not working, it says cannot build wheels for hnswlib. I tried with adding the build tools and every damn thing. Is there a real step by step for this. I have already tried 3 times now.

ppcmaverick avatar May 25 '23 10:05 ppcmaverick

Where to setup the Path Variable?

ppcmaverick avatar May 25 '23 10:05 ppcmaverick

@ppcmaverick

To set up Python in the PATH environment variable,

  1. Determine the Python installation directory:

    • If you are using the Python installed from python.org, the default installation location on Windows is typically C:\PythonXX (XX represents the version number).
    • If you are using Anaconda or Miniconda, the installation location is usually C:\Users\YourUsername\Anaconda3 or C:\Users\YourUsername\Miniconda3, respectively.
  2. Open the Control Panel:

    • Press the Windows key on your keyboard.
    • Type "Control Panel" and select it from the search results.
  3. Go to System and Security:

    • In the Control Panel, click on "System and Security."
  4. Click on "System":

    • Under the "System" section, click on "System" to open the system properties.
  5. Click on "Advanced system settings":

    • On the left-hand side of the "System" window, click on "Advanced system settings" to open the System Properties dialog box.
  6. Click on "Environment Variables":

    • In the System Properties dialog box, click on the "Environment Variables" button.
  7. Edit the PATH variable:

    • In the "Environment Variables" dialog box, locate the "Path" variable under the "System variables" section and select it.
    • Click on the "Edit" button to modify the PATH variable.
  8. Add Python to the PATH:

    • In the "Edit Environment Variable" dialog box, click on the "New" button.
    • Enter the path to the Python installation directory (step 1) by adding the following entry:
      • For Python from python.org: C:\PythonXX (replace XX with the version number).
      • For Anaconda or Miniconda: C:\Users\YourUsername\Anaconda3 or C:\Users\YourUsername\Miniconda3, respectively.
    • Click "OK" to save the changes.
  9. Close the dialog boxes:

    • Close all the dialog boxes by clicking "OK" or "Apply" until you return to the Control Panel.
  10. Open a new command prompt:

    • Open a new command prompt or PowerShell window to verify that Python is correctly set up in the PATH.
    • Type python or python --version and press Enter.
    • If Python is set up correctly, you should see the Python version information printed on the screen without any errors.

jackfood avatar May 25 '23 13:05 jackfood

I tried upgrading and installing wheel, langchain dependencies, c++ compilers. But still I still got the same error(s) using Ubuntu 22.04. A Docker image would be nice for this.

prezire avatar May 25 '23 16:05 prezire

https://visualstudio.microsoft.com/visual-cpp-build-tools/

Just to be clear, this downloads a windows exe which is not for M1 Mac.
Mac has clang.

On Mac, you will need the Command Line Tools for XCode (match your version and download from your developer login (developer.apple.com/download) The hint was seeing this error in output BEFORE the Failed to build llama-cpp-python hnswlib lxml

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

After installing, open new terminal window, change to the directory where you cloned the repo and rerun pip3 install -r requirements.txt

Keith-Albright-Bose avatar May 25 '23 18:05 Keith-Albright-Bose

I was getting the same issue with Python3.10.x versions. However, I managed to solve them by upgrading to Python3.11.3.

All dependencies were installed successfully for Python3.11.3. I have used pyenv to install custom Python versions.

albertas avatar May 26 '23 20:05 albertas

I'm also facing the face issue ( I tried with Ubuntu and Cent OS - both failed with the same error),

Hi, I have successfully installed this project in WSL2 (ubuntu 22.04). In order to install all requirements, I run these codes: $sudo apt update $sudo apt install g++ gdb make ninja-build rsync zip $pip3 install -r requirements.txt

qikongwanli avatar May 27 '23 17:05 qikongwanli

Upgraded to latest gcc-11/g++-11, pip and python 3.11.3 via pyenv but still nothing works on Ubuntu 22.04.

prezire avatar May 29 '23 17:05 prezire

For CentOS, you may find this useful: https://zhuanlan.zhihu.com/p/632202007, it's in Chinese though.

TianruiZhang avatar May 30 '23 10:05 TianruiZhang

image The red marked are the Microsoft C++ Build Tools components that i have installed @Angurajdin Can u pls check if i missed anything or if its correct what should i do further to fix this issue

you also have to install cli 2 it use cli to compile it

aminlv avatar Jun 02 '23 09:06 aminlv

Had the same issue with Ubuntu 18.04.6 and I was able to make it work following the instructions to update gcc-11 and g++-11 on this post.

emreg00 avatar Jun 02 '23 09:06 emreg00

centos7 update cmake to 3.2.5 and update gcc to 12.3 create soft link ln -s /install_dir/bin /usr/bin/gcc ln -s /usr/bin/gcc /usr/bin/cc

Naniyaking avatar Jul 18 '23 03:07 Naniyaking

I'm facing the same issue, I'm trying to develop this on Linux Fedora, can anyone help?

HN026 avatar Jul 26 '23 17:07 HN026

I solved the error by doing this:

pip3 uninstall -y -r requirements.txt
pip3 install --upgrade setuptools wheel
pip3 install -r requirements.txt

cassina avatar Jul 31 '23 23:07 cassina

I solved the error by doing this:

pip3 uninstall -y -r requirements.txt
pip3 install --upgrade setuptools wheel
pip3 install -r requirements.txt

It works on my macos

elseifer avatar Aug 06 '23 02:08 elseifer

I solved the error by doing this:

pip3 uninstall -y -r requirements.txt
pip3 install --upgrade setuptools wheel
pip3 install -r requirements.txt

Tried this on ubuntu, still not working... here's the output for ref

       [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for llama-cpp-python
Building wheel for peft (pyproject.toml) ... done
Created wheel for peft: filename=peft-0.5.0.dev0-py3-none-any.whl size=73122 sha256=d3fdf2edb73ba9cbda0feeca0ad8fdb89b54717d3b07536119f3c3856d74cee2
Stored in directory: /home/unify/.cache/pip/wheels/ff/57/c1/a023c490307cd8ffa3b61c86c48d9767f0bb850053af18674b
Building wheel for transformers (pyproject.toml) ... done
Created wheel for transformers: filename=transformers-4.32.0.dev0-py3-none-any.whl size=7446865 sha256=bdb52dcd91380dd75626d7e7992706bb208aa34866a953b98a6acb8718162beb
Stored in directory: /home/unify/.cache/pip/wheels/f6/48/92/9e4123ac1ebdcbfb22ad4c8490a4c2425b143314be3957af7b
Successfully built peft transformers
Failed to build llama-cpp-python
ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects

sanjana-sudo avatar Aug 14 '23 09:08 sanjana-sudo

I solved the issue on my WSL shown below.

on WSL1 Centos7:

yum install centos-release-scl
yum install devtoolset-9-gcc-c++
scl enable devtoolset-9 bash
pip3 install -r requirements.txt

on WSL2 Ubuntu 22.04.2 LTS:

sudo apt-get install python3.10-dev
pip3 install -r requirements.txt

tkni2005 avatar Aug 19 '23 17:08 tkni2005

I solved the issue on my WSL shown below.

on WSL1 Centos7:

yum install centos-release-scl
yum install devtoolset-9-gcc-c++
scl enable devtoolset-9 bash
pip3 install -r requirements.txt

on WSL2 Ubuntu 22.04.2 LTS:

sudo apt-get install python3.10-dev
pip3 install -r requirements.txt

Tried it on Ubuntu 22.04.3 LTS. Still facing the same error:

ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects

Is there something crucial I'm missing? like gpu requirements?

sanjana-sudo avatar Aug 21 '23 05:08 sanjana-sudo

This is all because of gcc/c++ version is too low.

I fixed by running as below

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
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 60 --slave /usr/bin/g++ g++ /usr/bin/g++-11

(Ubuntu 18.04)

And make sure your python version is 3.11+. Reference: Install gcc in ubuntu

JiaYingLii avatar Aug 23 '23 06:08 JiaYingLii