vtraag / louvain-igraph

Implementation of the Louvain algorithm for community detection with various methods for use with igraph in python.
GNU General Public License v3.0
246 stars 46 forks source link

install louvain issue for macOS #52

Closed mengwei02 closed 4 years ago

mengwei02 commented 4 years ago

Hi,

I have some issue with installation of louvain for macOS. I have installed python-igraph version 0.8.0 and it works well. When there is some issue to install louvain by using the command: sudo pip install louvain. The details are attached as follows. Could you please help me to solve this. Thank you so much in advance. Looking forward to your reply.

wc-dhcp38d180:~ user$ python Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import igraph print(igraph.version) 0.8.0 import louvain Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'louvain'

[1]+ Stopped python wc-dhcp38d180:~ user$ sudo pip install louvain Password: WARNING: The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting louvain Downloading louvain-0.6.1.tar.gz (84 kB) |████████████████████████████████| 84 kB 3.7 MB/s Requirement already satisfied: python-igraph>=0.7.1.0 in /anaconda3/lib/python3.6/site-packages (from louvain) (0.8.0) Requirement already satisfied: texttable>=1.6.2 in /anaconda3/lib/python3.6/site-packages (from python-igraph>=0.7.1.0->louvain) (1.6.2) Building wheels for collected packages: louvain Building wheel for louvain (setup.py) ... error ERROR: Command errored out with exit status 1: command: /anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-h9qyyj5m/louvain/setup.py'"'"'; file='"'"'/private/tmp/pip-install-h9qyyj5m/louvain/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-0d36i606 cwd: /private/tmp/pip-install-h9qyyj5m/louvain/ Complete output (85 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.7-x86_64-3.6 creating build/lib.macosx-10.7-x86_64-3.6/louvain copying src/functions.py -> build/lib.macosx-10.7-x86_64-3.6/louvain copying src/Optimiser.py -> build/lib.macosx-10.7-x86_64-3.6/louvain copying src/VertexPartition.py -> build/lib.macosx-10.7-x86_64-3.6/louvain copying src/_version.py -> build/lib.macosx-10.7-x86_64-3.6/louvain copying src/init.py -> build/lib.macosx-10.7-x86_64-3.6/louvain Fixing build/lib.macosx-10.7-x86_64-3.6/louvain/functions.py build/lib.macosx-10.7-x86_64-3.6/louvain/Optimiser.py build/lib.macosx-10.7-x86_64-3.6/louvain/VertexPartition.py build/lib.macosx-10.7-x86_64-3.6/louvain/_version.py build/lib.macosx-10.7-x86_64-3.6/louvain/init.py Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: ws_comma Fixing build/lib.macosx-10.7-x86_64-3.6/louvain/functions.py build/lib.macosx-10.7-x86_64-3.6/louvain/Optimiser.py build/lib.macosx-10.7-x86_64-3.6/louvain/VertexPartition.py build/lib.macosx-10.7-x86_64-3.6/louvain/_version.py build/lib.macosx-10.7-x86_64-3.6/louvain/init.py Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: ws_comma UPDATING build/lib.macosx-10.7-x86_64-3.6/louvain/_version.py set build/lib.macosx-10.7-x86_64-3.6/louvain/_version.py to '0.6.1' running build_ext Cannot find the C core of igraph on this system using pkg-config. We will now try to download and compile the C core from scratch. Version number of the C core: 0.7.1

Downloading igraph-0.7.1.tar.gz... 100.00% Extracting igraph-0.7.1.tar.gz... Configuring igraph... checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... ./install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in /private/tmp/igraph.lvg7m9kg/igraph-0.7.1': configure: error: cannot run C compiled programs. If you meant to cross compile, use--host'. See `config.log' for more details Could not download and compile the C core of igraph.

WARNING: we were not able to detect where igraph is installed on your machine (if it is installed at all). We will use the fallback library and include paths hardcoded in setup.py and hope that the C core of igraph is installed there.

If the compilation fails and you are sure that igraph is installed on your machine, adjust the following two variables in setup.py accordingly and try again:

mengwei02 commented 4 years ago

Hi Dr. Traag, I tried command "conda install -c conda-forge leidenalg". It works now. Thank you for your attention. I have one more question. As you said in the readme file that the Leiden algorithm is an extension of the Louvain algorithm. If I only wanna run the classic louvain algorithm, how should do by using leidenalg package in python? Thank you.

vtraag commented 4 years ago

Good to hear you got it working. I'm in the process of upgrading the louvain-igraph and leidenalg packages to igraph C core 0.8.0, but I haven't yet gotten around to it yet.

In principle, leidenalg no longer supports the Louvain method exactly. You can turn off the refinement phase of the Leiden algorithm, but you cannot turn off the "Fast Move Nodes". Using the "Fast Move Nodes", instead of the regular "Move Nodes", as in Louvain, might hurt the quality of the resulting partition, but it will be much faster. So, in short: if you want the classical Louvain algorithm, use louvain-igraph.

mengwei02 commented 4 years ago

OK, I see, Dr. Traag. Thank you so much for your reply.