【问题标题】:Unable to install igraph due to failing build for the C core由于 C 核心的构建失败,无法安装 igraph
【发布时间】:2021-12-31 11:39:02
【问题描述】:

我一直在尝试使用 pip 安装 igraph,但一直失败。 我收到以下错误:

  Using cached igraph-0.9.8.tar.gz (3.6 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: texttable>=1.6.2 in c:\msys64\mingw64\lib\python3.9\site-packages (from igraph) (1.6.4)
Building wheels for collected packages: igraph
  Building wheel for igraph (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\msys64\mingw64\bin\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-nrm8rlun\\igraph_85a609eb9b2b457aa62af06569648cc8\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-nrm8rlun\\igraph_85a609eb9b2b457aa62af06569648cc8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\HP\AppData\Local\Temp\pip-wheel-6pxfcwpb'
       cwd: C:\Users\HP\AppData\Local\Temp\pip-install-nrm8rlun\igraph_85a609eb9b2b457aa62af06569648cc8\
  Complete output (65 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.mingw_x86_64-3.9
  creating build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\clustering.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\configuration.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\cut.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\datatypes.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\formula.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\layout.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\matching.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\operators.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\sparse_matrix.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\statistics.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\summary.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\utils.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\version.py -> build\lib.mingw_x86_64-3.9\igraph
  copying src\igraph\__init__.py -> build\lib.mingw_x86_64-3.9\igraph
  creating build\lib.mingw_x86_64-3.9\igraph\app
  copying src\igraph\app\shell.py -> build\lib.mingw_x86_64-3.9\igraph\app
  copying src\igraph\app\__init__.py -> build\lib.mingw_x86_64-3.9\igraph\app
  creating build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\baseclasses.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\colors.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\coord.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\edge.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\graph.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\metamagic.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\shapes.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\text.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\utils.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\vertex.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  copying src\igraph\drawing\__init__.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
  creating build\lib.mingw_x86_64-3.9\igraph\remote
  copying src\igraph\remote\gephi.py -> build\lib.mingw_x86_64-3.9\igraph\remote
  copying src\igraph\remote\__init__.py -> build\lib.mingw_x86_64-3.9\igraph\remote
  running build_ext
  running build_c_core
  -- Building for: NMake Makefiles
  -- Setting build type to 'Release' as none was specified.
  -- Version number: 0.9.4-24-gb29e741ea
  CMake Error at CMakeLists.txt:30 (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!
  See also "C:/Users/HP/AppData/Local/Temp/pip-install-nrm8rlun/igraph_85a609eb9b2b457aa62af06569648cc8/vendor/build/igraph/CMakeFiles/CMakeOutput.log".
  We are going to build the C core of igraph.
    Source folder: vendor\source\igraph
    Build folder: vendor\build\igraph
    Install folder: vendor\install\igraph

  Configuring build...
  Build failed for the C core of igraph.

  ----------------------------------------
  ERROR: Failed building wheel for igraph
  Running setup.py clean for igraph
Failed to build igraph
Installing collected packages: igraph
    Running setup.py install for igraph ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\msys64\mingw64\bin\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-nrm8rlun\\igraph_85a609eb9b2b457aa62af06569648cc8\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-nrm8rlun\\igraph_85a609eb9b2b457aa62af06569648cc8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-vzu8m8eh\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\msys64\mingw64\include\python3.9\igraph'
         cwd: C:\Users\HP\AppData\Local\Temp\pip-install-nrm8rlun\igraph_85a609eb9b2b457aa62af06569648cc8\
    Complete output (65 lines):
    running install
    C:\msys64\mingw64\lib\python3.9\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    running build
    running build_py
    creating build
    creating build\lib.mingw_x86_64-3.9
    creating build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\clustering.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\configuration.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\cut.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\datatypes.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\formula.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\layout.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\matching.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\operators.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\sparse_matrix.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\statistics.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\summary.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\utils.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\version.py -> build\lib.mingw_x86_64-3.9\igraph
    copying src\igraph\__init__.py -> build\lib.mingw_x86_64-3.9\igraph
    creating build\lib.mingw_x86_64-3.9\igraph\app
    copying src\igraph\app\shell.py -> build\lib.mingw_x86_64-3.9\igraph\app
    copying src\igraph\app\__init__.py -> build\lib.mingw_x86_64-3.9\igraph\app
    creating build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\baseclasses.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\colors.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\coord.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\edge.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\graph.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\metamagic.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\shapes.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\text.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\utils.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\vertex.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    copying src\igraph\drawing\__init__.py -> build\lib.mingw_x86_64-3.9\igraph\drawing
    creating build\lib.mingw_x86_64-3.9\igraph\remote
    copying src\igraph\remote\gephi.py -> build\lib.mingw_x86_64-3.9\igraph\remote
    copying src\igraph\remote\__init__.py -> build\lib.mingw_x86_64-3.9\igraph\remote
    running build_ext
    running build_c_core
    -- Version number: 0.9.4-24-gb29e741ea
    CMake Error at CMakeLists.txt:30 (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!
    See also "C:/Users/HP/AppData/Local/Temp/pip-install-nrm8rlun/igraph_85a609eb9b2b457aa62af06569648cc8/vendor/build/igraph/CMakeFiles/CMakeOutput.log".
    We are going to build the C core of igraph.
      Source folder: vendor\source\igraph
      Build folder: vendor\build\igraph
      Install folder: vendor\install\igraph

    Configuring build...
    Build failed for the C core of igraph.

    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\msys64\mingw64\bin\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-nrm8rlun\\igraph_85a609eb9b2b457aa62af06569648cc8\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-nrm8rlun\\igraph_85a609eb9b2b457aa62af06569648cc8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-vzu8m8eh\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\msys64\mingw64\include\python3.9\igraph' Check the logs for full command output.

这个问题与构建 igraph 的 C 核心有关。我应该采取哪些步骤来解决此错误?

我的系统信息(如果相关):

  • HP 14 号亭
  • 英特尔酷睿 i7-1065G7 CPU
  • Windows 10 家庭版 21H1 64 位
  • Python 3.9.7
  • 点 21.3.1

【问题讨论】:

  • github.com/igraph/… : "确保您已安装 Microsoft Visual Studio 2015 或更高版本..."
  • 您似乎正在使用来自 MSYS2 的 Python。为什么?为什么不使用由 MSVC 构建的 Python 发行版,因此与 PyPI 的 Windows 轮子兼容,例如官方 Python 发行版或 Anaconda?
  • 澄清一下,python-igraph 没有明确支持 MSYS2。可能需要付出一些努力才能使其工作,但是除非您有充分的理由在该环境中使用 Python,否则这样做是没有意义的。完全支持官方 Python 发行版,Anaconda 也是如此。两者都可以使用预编译的二进制文件。

标签: python python-3.x pip igraph


【解决方案1】:

tl;dr 使用适用于 Windows 的官方 Python 发行版,或使用 Anaconda。


除非有充分的理由,否则不应将 python-igraph 与 MSYS2 中包含的 Python 一起使用。此 Python 与 Windows 上的官方 Python 发行版不兼容,这意味着您将无法从 PyPI 安装二进制轮子,并且需要从源代码编译所有内容。正如您所发现的,这并不总是微不足道的。

如果您有充分的理由将此 Python 与 igraph 一起使用,最简单的方法如下:

走这条路,你就踏入了未知的水域。期待您需要自己解决的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    • 2018-12-03
    • 1970-01-01
    • 1970-01-01
    • 2018-10-07
    • 1970-01-01
    相关资源
    最近更新 更多