windows安装llama-cpp-python遇到错

(venv) PS D:\PycharmProjects\langChainLearn> pip install llama-cpp-python
Collecting llama-cpp-python
  Using cached llama_cpp_python-0.2.6.tar.gz (1.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: typing-extensions>=4.5.0 in d:\pycharmprojects\langchainlearn\venv\lib\site-packages (from llama-cpp-python) (4.7.1)
Requirement already satisfied: numpy>=1.20.0 in d:\pycharmprojects\langchainlearn\venv\lib\site-packages (from llama-cpp-python) (1.25.2)
Collecting diskcache>=5.6.1 (from llama-cpp-python)
  Obtaining dependency information for diskcache>=5.6.1 from https://files.pythonhosted.org/packages/3f/27/4570e78fc0bf5ea0ca45eb1de3818a23787af9b3
90c0b0a0033a1b8236f9/diskcache-5.6.3-py3-none-any.whl.metadata
  Using cached diskcache-5.6.3-py3-none-any.whl.metadata (20 kB)
Using cached diskcache-5.6.3-py3-none-any.whl (45 kB)
Building wheels for collected packages: llama-cpp-python
  Building wheel for llama-cpp-python (pyproject.toml) ... error
  error: subprocess-exited-with-error                                             
                                                                                  
  × Building wheel for llama-cpp-python (pyproject.toml) did not run successfully.
  │ exit code: 1                                                                  
  ╰─> [20 lines of output]
      *** scikit-build-core 0.5.0 using CMake 3.27.5 (wheel)
      *** Configuring CMake...
      2023-09-18 16:59:04,497 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=No
      loading initial cache file C:\Users\z00498ta\AppData\Local\Temp\tmpgz_51jr8\build\CMakeInit.txt
      -- Building for: NMake Makefiles
      CMake Error at CMakeLists.txt:3 (project):
        Running
     
         'nmake' '-?'
     
        failed with:
     
         The system cannot find the file specified
     
     
      CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
      CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
      -- Configuring incomplete, errors occurred!
     
      *** CMake configuration failed
      [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
Failed to build llama-cpp-python
ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects
(venv) PS D:\PycharmProjects\langChainLearn> 
(venv) PS D:\PycharmProjects\langChainLearn> 

先尝试下了个CMaker 3.27.5 在windows机器安装了 (看见上面的日志里提的是这个版本)Download | CMake
但 好像是有些变量要设置,但是现在不清楚改怎么设置。

1 Like

conda install -c conda-forge c-compiler
conda install -c "conda-forge/label/cf202003" c-compiler
试一下这两句,重新安装一下编译器再试试看是不是能正常安装。

我的windows机器没法直接运行这2条命令

conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.   
At line:1 char:1                                                                         
+ conda active venv                                                                      
+ ~~~~~                                                                                  
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException                                   
                                                             

如果手动安装conda 是不是比较麻烦?

哦,我可能搞混了,之前有个人是装了anaconda的环境

等回复,我也一样的问题

可能不少windows机器的同学会遇到这个问题,这个问题如果解决不了会影响后面的上课吗?
我没有anaconda的环境 看错误应该不涉及这个

根据下面的连接 现在准备 新装个VisualStudio 2022 + C++ building tool再重新安装试试
https://github.com/abetlen/llama-cpp-python/issues/54

 Building windows wheels for Python 3.10 requires Microsoft Visual Studio 2022.
1 Like

我已经安装这个解决了,可以的,记得选组件是要选C++桌面开发的

嗯 那就好 我还在下载 :smile:


结贴!按上面的方式 重启机器后 安装上可以 运行
上个截图

1 Like