Msys2 Python Windows Instructions incomplete cmake nor build_c_core work

I attempted to follow the instructions here
Installation gave me a bunch of errors:
ex.

  ERROR: Command errored out with exit status 1:
   command: C:/msys64/mingw64/bin/python3.9.exe -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/setup.py'"'"'; __file__='"'"'C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/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/bizo2/AppData/Local/Temp/pip-wheel-0_gkouvx
       cwd: C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/
  Complete output (55 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
  -- Setting build type to 'Release' as none was specified.
  -- Version number: 0.9.4
  CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
  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/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/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 python-igraph
    ERROR: Command errored out with exit status 1:
     command: C:/msys64/mingw64/bin/python3.9.exe -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/setup.py'"'"'; __file__='"'"'C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/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/bizo2/AppData/Local/Temp/pip-record-0fx1_t5z/install-record.txt --single-version-externally-managed --compile --install-headers C:/msys64/mingw64/include/python3.9/python-igraph
         cwd: C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/
    Complete output (54 lines):
    running install
    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
    CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
    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/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/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/python3.9.exe -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/setup.py'"'"'; __file__='"'"'C:/Users/bizo2/AppData/Local/Temp/pip-install-kzk0ll93/python-igraph_155f70f545dd48c1a074a55fb9ca32bb/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/bizo2/AppData/Local/Temp/pip-record-0fx1_t5z/install-record.txt --single-version-externally-managed --compile --install-headers C:/msys64/mingw64/include/python3.9/python-igraph Check the logs for full command output.

Then I began Compiling from source, but that did not work. Even adding the paths in the image to pkg-config did not succeed.

I would not recommend using MSYS2 to work with python-igraph unless you have a very good reason. We provide pre-compiled Windows binaries for the official Windows Python (which I believe is not binary compatible with the one in MSYS2). You can also get python-igraph for Windows from Anaconda.

If you want to use MSYS2 anyway, you will need to compile python-igraph from source. However, you may not need to compile igraph’s C core from source as well. Instead, install it from MSYS2:

https://packages.msys2.org/package/mingw-w64-x86_64-igraph?repo=mingw64

Now check the pkg-config --cflags --libs igraph again. This time it should work.

If you want to let the C core be compiled from source as well, be sure to check the instructions: igraph Reference Manual You must be consistent with using the mingw64 msys terminal, and installing the mingw-w64-x86_64 variants of tools. This means that you should not install the cmake package, but the mingw-w64-x86_64-cmake one.

If you still encounter problems, please show us the complete sequence of commands you used, and please put the output in code boxes for readability. See How to use this forum? for formatting instructions.

Spyder does not find igraph, when I run the tests. I even setup a separate environment. Anaconda shows 0.9.6 igraph, but python cannot find/use it. Windows 10 seems to really not like igraph.
Anaconda even shows igraph 0.9.6 as an installed package

Running Spyder under that gives:
ModuleNotFoundError: No module named 'igraph.test
for:
import igraph.test
igraph.test.run_tests()

neither does:
import igraph as ig
g = ig.Graph.Famous(“petersen”)
ig.plot(g)

work(it gives “TypeError: runfile() got an unexpected keyword argument ‘current_namespace’”)

I will try your other suggestions and post back here.
TYVM!

I did get did get one step further for the igraph 0.9.6 install, but then failed the cmake again.

bizo2@DESKTOP-23434UQ MINGW64 /C/msys64/home/bizo2/python-igraph-0.9.6
$ python setup.py install
running install
running bdist_egg
running egg_info
writing python_igraph.egg-info/PKG-INFO
writing dependency_links to python_igraph.egg-info/dependency_links.txt
writing requirements to python_igraph.egg-info/requires.txt
writing top-level names to python_igraph.egg-info/top_level.txt
reading manifest file 'python_igraph.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'vendor/source/igraph/etc/abstracts'
no previously-included directories found matching 'vendor/source/igraph/etc/papers'
no previously-included directories found matching 'vendor/source/igraph/etc/presentations'
no previously-included directories found matching 'vendor/source/igraph/interfaces'
no previously-included directories found matching 'vendor/source/igraph/vendor/simpleraytracer'
adding license file 'LICENSE'
adding license file 'COPYING'
writing manifest file 'python_igraph.egg-info/SOURCES.txt'
installing library code to build/bdist.mingw_x86_64/egg
running install_lib
running build_py
running build_ext
running build_c_core
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...
CMake Error: The current CMakeCache.txt directory C:/msys64/home/bizo2/python-igraph-0.9.6/vendor/build/igraph/CMakeCache.txt is different than the directory /home/bizo2/python-igraph-0.9.6/vendor/build/igraph where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source "C:/msys64/home/bizo2/python-igraph-0.9.6/vendor/source/igraph/CMakeLists.txt" does not match the source "/home/bizo2/python-igraph-0.9.6/vendor/source/igraph/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
Build failed for the C core of igraph.

I would prefer Anaconda, over MSYS2 MiniGW 64-bit, but I cannot get either to work for Windows 10. I will look more into the 0.9.4, and continue to play arounddddd

After install i can get to Spyder from preferences. This python.exe interpreter, still fails, given the steps so far

Is this why you are trying to compile it with MSYS2? If so, I strongly recommend you do not use MSYS2 for this.

It sounds like your actual problem is just getting Spyder to use the specific conda environment where you installed python-igraph. Is this correct?

You need to make sure that Spyder is also installed in your environment myenv, otherwise you will launch Spyder from the base environment.

You can do this from the Anaconda navigator. You can also do this from the Anaconda prompt, which is sometimes a bit more explicit and hence clear. If you launch the Anaconda prompt, you can first activate that environment by using

conda activate myenv

and then make sure you install spyder

conda install spyder

and finally launch spyder using

spyder

Perhaps before going into the question of whether Spyder is correctly installed and can find python-igraph, you can first simply check whether igraph is installed correctly from the Anaconda prompt. After you have activated the environment using conda activate myenv, you launch python from that environment by simply typing python. You can then manually type import igraph inside Python. If that also raises an error let us know. If that does work correctly, it is indeed a problem of Spyder, not of python-igraph.

My actual problem is getting nay igraph to work on Windows 10 by any means necessary. Anaconda nor MSYS2 seem to function as intended, but such is software compatibility at times. Patience as power you are lending me very much.

I would much prefer Spyder or some other IDE, but I only have 7 lines of code I really want to run.
Thank You!

TYVM
Closer
I can run python in the anaconda console, but then it looks like python crashes:

(myenv) PS C:\WINDOWS\system32> python
Python 3.8.11 (default, Aug  6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import igraph as ig
>>> import pandas as pd
>>> os.chdir("C:/Users/bizo2/Desktop")
>>> df=pd.read_excel("edgelist2.xlsx")
>>> g = ig.Graph.Read_Ncol(df)
(myenv) PS C:\WINDOWS\system32>

Edit: It looks like it does not install there either:

(base) PS C:\WINDOWS\system32> conda activate myenv
(myenv) PS C:\WINDOWS\system32> python
Python 3.8.11 (default, Aug  6 2021, 09:57:55) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph.test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'igraph.test'
>>>

This is not expected to work. Tests don’t ship with python-igraph.

Please give us a complete reproducible example, including the data file.

python-igraph fully supports Windows 10, and is regularly tested on that platform, both as a 32-bit and 64-bit build. (See e.g. here) I do not think that the problems you encounter are related to Windows.

I now notice that you are trying to apply Read_Ncol to a Pandas dataframe. The input to this function should be a file name: python-igraph API reference

That said, it should not cause a crash, so a reproducible example would be useful.

If you need to construct a graph from a Pandas DataFrame, you might find this function useful: python-igraph API reference

1 Like

I will take a look at this later. I do not know whom to contact, but the documentation in this page should be updated

Installing igraph via Conda
Users of the Anaconda Python distribution or the conda package manager may opt to install igraph’s Python interface using conda. That can be achieved by running the following command:

$ conda install -c conda-forge python-igraph

To test the installed package, launch Python and run the following:

import igraph.test
igraph.test.run_tests()
The above commands run the bundled test cases to ensure that everything is fine with your igraph installation.

This solution is value added to my organization, but I have other priorities today.

Again thank you so very much.

I pulled the dataframe solution from stack exchange, so who knows. The lack of ‘.csv’ and instead white space is frustrating, but I maybe able to finagle right from notepad.

Yes, absolutely right, I’ve opened a PR to correct those instructions, you can follow the progress here.

I’ve also opened an issue for this.

Essentially reading an edge list from a file using pandas and creating a graph should be done like

df = pd.read_excel("edgelist2.xlsx")
g = ig.Graph.DataFrame(df)

If this does not work, let us know.