[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Python3 igraph import error on Cygwin

From: Tamás Nepusz
Subject: Re: [igraph] Python3 igraph import error on Cygwin
Date: Thu, 25 Apr 2013 12:29:15 +0200


Oh, hang on, I think I *may* figured it out. On Linux and Mac OS X, the names 
of "hidden" files (i.e. configuration files and whatnot that should not be seen 
by the user with an ordinary "ls" command) start with a dot. I vaguely remember 
that Cygwin fakes this by using an underscore as the first character of the 
filename and translating it to a dot on-the-fly so the software running 
"inside" Cygwin sees the dot while the real filename starts with an underscore. 
I'm not sure because it's been a while since I used Cygwin for the last time, 
but it seems like this is the reason why a file named _igraph.py on the disk is 
not seen by Python (because Python would see it as ".igraph.py"). Can you try 
the following?

1. Rename _igraph.py to, say, igraph_core.py
2. Similarly, rename _igraph.cpython-32m.dll to igraph_core.cpython-32m.dll
3. Update the DLL filename in the __bootstrap__ function of igraph_core.py
4. Update __init__.py to use "from igraph.igraph_core import *" instead of 
"from igraph._igraph import *"

You may also have to replace "igraph._igraph" with "igraph.igraph_core" in 
other places in the library such as clustering.py, drawing/graph.py, 
matching.py and statistics.py.


On 25 Apr 2013, at 06:35, Stephen J. Gaffigan <address@hidden> wrote:

> Hi Tamas,
> Thanks a lot for your detailed suggestions. I tried again with 
> /usr/local/igraph/lib (which contains the .dll) in the LD_LIBRARY_PATH, but 
> still get the same error. Some more output is below. It doesn't look like 
> LD_DEBUG is working for me under Cygwin, though it could be that I'm missing 
> something in my Cygwin environment that would enable support for this. I have 
> a very minimal set of packages installed. It was _igraph.py that I was 
> looking at, though there's also an _igraph.cpython-32m.dll, which is loaded 
> through _igraph.py (see below).
> $ ls /usr/local/igraph/lib
> cygigraph-0.dll  libigraph.a  libigraph.dll.a  libigraph.la  pkgconfig
> $ set | grep LD_LIBRARY_PATH
> LD_LIBRARY_PATH=/usr/local/igraph/lib
> $ LD_DEBUG=all python3 -c "import igraph"
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File 
> "/usr/local/lib/python3.2/site-packages/python_igraph-0.6.5-py3.2-cygwin-1.7.18-i686.egg/igraph/__init__.py",
>  line 34, in <module>
>     from igraph._igraph import *
> ImportError: No such file or directory
> $ ls 
> /usr/local/lib/python3.2/site-packages/python_igraph-0.6.5-py3.2-cygwin-1.7.18-i686.egg/igraph/
> __init__.py              clustering.py     drawing      remote         vendor
> __pycache__              compat.py         formula.py   statistics.py
> _igraph.cpython-32m.dll  configuration.py  layout.py    summary.py
> _igraph.py               cut.py            matching.py  test
> app                      datatypes.py      nexus.py     utils.py
> $ cat 
> /usr/local/lib/python3.2/site-packages/python_igraph-0.6.5-py3.2-cygwin-1.7.18-i686.egg/igraph/_igraph.py
> def __bootstrap__():
>    global __bootstrap__, __loader__, __file__
>    import sys, pkg_resources, imp
>    __file__ = 
> pkg_resources.resource_filename(__name__,'_igraph.cpython-32m.dll')
>    __loader__ = None; del __bootstrap__, __loader__
>    imp.load_dynamic(__name__,__file__)
> __bootstrap__()
> At this point I don't really need to figure this out. I was able to run my 
> script by installing the pre-compiled Python, igraph, etc. Windows binaries 
> and calling python3.exe through Cygwin. I just needed to provide instructions 
> how to run my script, which uses igraph, through Cygwin.
> Thanks again for your help. Let me know if there's anything else you want me 
> to try or look at on this.
> Steve
> On Wed, Apr 24, 2013 at 2:45 PM, Tamás Nepusz <address@hidden> wrote:
> Hi,
> > No such luck. The usual import error I get with a fresh install of igraph 
> > from source is because the shared library isn't found because I forget to 
> > add a /etc/ld.so.conf.d/igraph.conf file or update LD_LIBRARY_PATH. This is 
> > different (though I admit I did still try LD_LIBRARY_PATH with 
> > /usr/local/igraph/lib and even the egg/igraph directory, which contains a 
> > .dll).
> Okay, so the story is as follows. You should have a file named libigraph.so 
> (or .dll, not sure what extension Cygwin uses) somewhere in your file system. 
> This is the C core of igraph, and the folder that contains this file should 
> be on your library path. If this folder is not /lib, /usr/lib or 
> /usr/local/lib, chances are that you need to add this permanently to your 
> On top of libigraph.so, we have a glue layer that sits between the Python 
> interface of igraph and the C core of igraph. This glue layer is the magic 
> igraph._igraph module that Python is looking for, and it should be in the 
> very same folder where the root __init__.py file of the Python interface is. 
> (Should be right within the .egg directory). The glue layer is usually named 
> _igraph.so, _igraph.dll, _igraph.pyd, _igraph.dylib or something like that, 
> depending on your platform. (Again, I'm not sure which one Cygwin uses). The 
> folder containing this file does not have to be added to LD_LIBRARY_PATH 
> because Python will do that automatically when the igraph module is loaded, 
> but the file should be there in the right place.
> Please check that you have both of these files at the right places. The 
> .egg-info file is not necessary as far as I know, it only contains metadata 
> that makes it easier for distutils and/or pip to uninstall or upgrade the 
> package.
> > I tried adding the egg directory to PYTHONPATH with no success. But the 
> > original error suggests that it was already finding the module in the egg. 
> > It's inside igraph/__init__.py when the import error occurs. But 
> > igraph/_igraph.py is there too, which is why I'm lost why it's not finding 
> > it.
> Is it really called _igraph.py and not _igraph.dll, _igraph.pyd or something 
> like that? Also, another option is to try debugging what the dynamic library 
> loader is actually doing when you try to import igraph. Try this:
> LD_DEBUG=libs python3 -c "import igraph"
> This will give you lots of information about what ld is doing (and you can 
> get even more info with LD_DEBUG=all); the relevant section looks like this 
> for me:
>      25408:     calling init: /home/tamas/lib/libigraph.so.0
>      25408:
>      25408:
>      25408:     calling init: 
> /home/tamas/virtualenvs/default/local/lib/python2.7/site-packages/python_igraph-0.7-py2.7-linux-x86_64.egg/igraph/_igraph.so
>      25408:
> Cheers,
> Tamas
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help

reply via email to

[Prev in Thread] Current Thread [Next in Thread]