vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
616 stars 78 forks source link

Install issuses in MAC (macOS Mojave with version 10.14.4) #19

Closed eleozzr closed 4 years ago

eleozzr commented 5 years ago
Collecting python-igraph>=0.7.1.0 (from leidenalg==0.7.0.post1+19.g0c2a937.dirty)
Building wheels for collected packages: leidenalg
  Building wheel for leidenalg (setup.py) ... error
  Complete output from command /Users/xiaoxiang/miniconda3/envs/py36/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-req-build-8_p5nia0/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/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-wheel-y7th2abw --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  UPDATING build/lib.macosx-10.7-x86_64-3.6/leidenalg/_version.py
  set build/lib.macosx-10.7-x86_64-3.6/leidenalg/_version.py to '0.7.0.post1+19.g0c2a937.dirty'
  running build_ext
  Build type: dynamic extension
  Include path: /usr/local/Cellar/igraph/0.7.1_6/include/igraph
  Library path: /usr/local/Cellar/igraph/0.7.1_6/lib
  Linked dynamic libraries: igraph
  Linked static libraries:
  Extra compiler options:
  Extra linker options:
  building 'leidenalg._c_leiden' extension
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/xiaoxiang/miniconda3/envs/py36/include -arch x86_64 -I/Users/xiaoxiang/miniconda3/envs/py36/include -arch x86_64 -Iinclude -I/usr/local/Cellar/igraph/0.7.1_6/include/igraph -I/Users/xiaoxiang/miniconda3/envs/py36/include/python3.6m -c src/SignificanceVertexPartition.cpp -o build/temp.macosx-10.7-x86_64-3.6/src/SignificanceVertexPartition.o -O3
  warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
  In file included from src/SignificanceVertexPartition.cpp:1:
  In file included from include/SignificanceVertexPartition.h:4:
  include/MutableVertexPartition.h:4:10: fatal error: 'string' file not found
  #include <string>
           ^~~~~~~~
  1 warning and 1 error generated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for leidenalg
  Running setup.py clean for leidenalg
Failed to build leidenalg
Installing collected packages: python-igraph, leidenalg
  Running setup.py install for leidenalg ... error
    Complete output from command /Users/xiaoxiang/miniconda3/envs/py36/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-req-build-8_p5nia0/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-record-65pc1iij/install-record.txt --single-version-externally-managed --compile:
    running install
    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/leidenalg
    copying src/functions.py -> build/lib.macosx-10.7-x86_64-3.6/leidenalg
    copying src/Optimiser.py -> build/lib.macosx-10.7-x86_64-3.6/leidenalg
    copying src/VertexPartition.py -> build/lib.macosx-10.7-x86_64-3.6/leidenalg
    copying src/_version.py -> build/lib.macosx-10.7-x86_64-3.6/leidenalg
    copying src/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/leidenalg
    Fixing build/lib.macosx-10.7-x86_64-3.6/leidenalg/functions.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/Optimiser.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/VertexPartition.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/_version.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/__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/leidenalg/functions.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/Optimiser.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/VertexPartition.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/_version.py build/lib.macosx-10.7-x86_64-3.6/leidenalg/__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/leidenalg/_version.py
    set build/lib.macosx-10.7-x86_64-3.6/leidenalg/_version.py to '0.7.0.post1+19.g0c2a937.dirty'
    running build_ext
    Build type: dynamic extension
    Include path: /usr/local/Cellar/igraph/0.7.1_6/include/igraph
    Library path: /usr/local/Cellar/igraph/0.7.1_6/lib
    Linked dynamic libraries: igraph
    Linked static libraries:
    Extra compiler options:
    Extra linker options:
    building 'leidenalg._c_leiden' extension
    creating build/temp.macosx-10.7-x86_64-3.6
    creating build/temp.macosx-10.7-x86_64-3.6/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/xiaoxiang/miniconda3/envs/py36/include -arch x86_64 -I/Users/xiaoxiang/miniconda3/envs/py36/include -arch x86_64 -Iinclude -I/usr/local/Cellar/igraph/0.7.1_6/include/igraph -I/Users/xiaoxiang/miniconda3/envs/py36/include/python3.6m -c src/SignificanceVertexPartition.cpp -o build/temp.macosx-10.7-x86_64-3.6/src/SignificanceVertexPartition.o -O3
    warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
    In file included from src/SignificanceVertexPartition.cpp:1:
    In file included from include/SignificanceVertexPartition.h:4:
    include/MutableVertexPartition.h:4:10: fatal error: 'string' file not found
    #include <string>
             ^~~~~~~~
    1 warning and 1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/xiaoxiang/miniconda3/envs/py36/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-req-build-8_p5nia0/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-record-65pc1iij/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/l9/xq949z0n50q3nywwb3rm3w2h0000gn/T/pip-req-build-8_p5nia0/

I try all possible solutions in https://github.com/vtraag/leidenalg/issues/1, but it still not works.

For reference

(py36) xiaoxiang@ele:leidenalg$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

and

(py36) xiaoxiang@ele:leidenalg$  brew info gcc

gcc: stable 9.2.0 (bottled), HEAD
GNU compiler collection
https://gcc.gnu.org/
/usr/local/Cellar/gcc/9.2.0 (1,462 files, 291.4MB) *
  Poured from bottle on 2019-09-08 at 19:13:53
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcc.rb
==> Dependencies
Required: gmp ✔, isl ✔, libmpc ✔, mpfr ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 75,462 (30 days), 206,663 (90 days), 923,390 (365 days)
install_on_request: 34,043 (30 days), 93,420 (90 days), 438,057 (365 days)
build_error: 0 (30 days)
vtraag commented 5 years ago

Could you try installing using conda? Unfortunately I have no Mac, making it a bit more difficult to properly test that platform. It seems to build correctly for the Mac from the conda-forge channel. You should be able to install it simply using

conda install -c conda-forge leidenalg 

If that does not work, please report back the error.

eleozzr commented 5 years ago

Thank you. But when I run the code

conda install -c conda-forge leidenalg 

It throws the following errors

(py36) xiaoxiang@ele:~$ conda install -c conda-forge leidenalg 
Collecting package metadata (current_repodata.json): failed

NotWritableError: The current user does not have write permissions to a required path.
  path: /Users/xiaoxiang/miniconda3/pkgs/cache/b35683e8.json
  uid: 501
  gid: 20

If you feel that permissions on this path are set incorrectly, you can manually
change them by executing

  $ sudo chown 501:20 /Users/xiaoxiang/miniconda3/pkgs/cache/b35683e8.json

In general, it's not advisable to use 'sudo conda'.

Even I run conda with sudo

(py36) xiaoxiang@ele:~$ sudo conda install -c conda-forge leidenalg 
Password:
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/xiaoxiang/miniconda3

  added / updated specs:
    - leidenalg

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2019.9.11          |           py37_0         147 KB  conda-forge
    conda-4.7.12               |           py37_0         3.0 MB  conda-forge
    ------------------------------------------------------------
                                           Total:         3.1 MB

The following packages will be UPDATED:

  ca-certificates    pkgs/main::ca-certificates-2019.8.28-0 --> conda-forge::ca-certificates-2019.9.11-hecc5488_0

The following packages will be SUPERSEDED by a higher-priority channel:

  certifi                                         pkgs/main --> conda-forge
  conda                                           pkgs/main --> conda-forge
  openssl              pkgs/main::openssl-1.1.1d-h1de35cc_2 --> conda-forge::openssl-1.1.1c-h01d97ff_0

Proceed ([y]/n)? y

Downloading and Extracting Packages
certifi-2019.9.11    | 147 KB    | ##################################################################################### | 100% 
conda-4.7.12         | 3.0 MB    | ##################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

It looks everything is ok. But when I run the example in https://github.com/vtraag/leidenalg, there is an error AttributeError: module 'leidenalg' has no attribute 'find_partition'. I don't know where I am wrong? Please see the details below.

(py36) xiaoxiang@ele:~$ python
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 14:01:38) 
[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 leidenalg
>>> import igraph as ig
>>> G = ig.Graph.Erdos_Renyi(100, 0.1)
>>> part = leidenalg.find_partition(G, leidenalg.ModularityVertexPartition)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'leidenalg' has no attribute 'find_partition'
vtraag commented 5 years ago

That is rather strange. What is the value of leidenalg.__path__? Perhaps something is going wrong with the permissions. Typically, you should install Anaconda as a user (i.e. don't use sudo when installing Anaconda).

vtraag commented 4 years ago

Right now, new binary wheels are being build for the new release, including for macOS. This should fix this issue.