Accessing Tulip bindings from the classical Python shell

Help
2013-05-01
2013-11-08
  • David Monarchi

    David Monarchi - 2013-05-01

    Hello -

    System: Win 7 Pro x64; Tulip 4.2

    I can successfully write Python code using the Tulip Python IDE. Now I am trying to write some Tulip modules in Python directly. I have updated the PATH and PYTHONPATH variables to include
    C:\Program Files (x86)\Tulip\bin\python
    and rebooted the machine.

    According to the Poster at http://hal.archives-ouvertes.fr/docs/00/74/49/69/ANNEX/EuroSciPy2012-TulipPython-Poster.pdf, accessing the Tulip module should be straightforward. That poster states:

        Interactive use
    Tulip bindings can be used through the classical
    Python shell (script and interactive mode)
    and give access to all graph algorithms and
    visualizations available in Tulip.
    Importing, customizing and visualizing a net-
    work can be done in a few lines of code, as
    illustrated by the snippet below which creates
    a visualization of the Python 2.7 library folder.
    
    >>> from tulip import *
    >>> from tulipgui import *
    # Call the File System import plugin on the Python 2.7 library folder
    >>> params == tlp.DataSet()
    >>> params["dir::directory"] == "/usr/lib/python2.7"
    >>> graph == tlp.importGraph("File System Directory", params)
    # Set nodes labels to filenames
    >>> graph["viewLabel"].copy(graph["name"])
    # Draw the graph
    >>> graph.applyLayoutAlgorithm("Bubble Tree", graph["viewLayout"])
    # Visualize the graph
    >>> view == tlp.addNodeLinkDiagramView(graph)
    >>> rp == view.getRenderingParameters()
    >>> rp.setLabelsDensity(0)
    >>> view.setRenderingParameters(rp)
    

    I tried to import tulip both from the Python shell and in interactive mode in a cmd window with the same result -- DLL load failed: The specified module could not be found. I confirmed that tulip.pyd is indeed in the correct subdirectory, so I'm at a bit of a loss.

    Any guidance/assistance would be very much appreciated. I suspect that I have not properly told Python where to look, but outside of the path parameters mentioned above, I don't know what else to set.

    Thank you.

    Best,
    David

     
    • mwolf

      mwolf - 2013-05-03

      Hi,

      I have the same problem using tulip in eclipse.
      The exact error message is:
      'from tulip import *
      ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.'

      Thanks in advance

      Regards
      Magnus

       
  • David Monarchi

    David Monarchi - 2013-05-07

    Hello -

    I have an update on my problem. I use PyCharm as an IDE, and can not import tulip into it. I reported this to the support group at PyCharm, and they have concluded the following:

     It seems that this library is not intended to be used outside of its main program. 
     You can file a feature request for Tulip support in PyCharm, since this library/tool 
     requires special handling.
    

    Is it possible that something is missing from the pyd file that keeps it from working outside of Tulip?

    Fwiw, below is what I get when I try to import the tulip file in the 2.7.2 interpreter. I printed out the PYTHONPATH first to confirm that it does indeed include the location of tulip.pyd.

    C:\>python
    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> print sys.path
    ['', 'C:\\Program Files (x86)\\Tulip\\bin\\python', 'C:\\Python27\\Lib\\idlelib', 'C:\\ C:\\Windows\\system32\\python27.zip', 'C:\\ C:\\Python27\\DLLs', 'C:\\ C:\\Python27\\lib', '
    

    C:\ C:\Python27\lib\plat-win', 'C:\ C:\Python27\lib\lib-tk', 'C:\ C:\Python27', 'C:\ C:\Python27\lib\site-packages', 'C:\Windows\system32\python27.zip', 'C:\Pytho
    n27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\
    setuptools-0.6c11-py2.7.egg-info']
    >>> import tulip
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: DLL load failed: The specified module could not be found.
    >>> quit()

    Any help/advice/assistance would be greatly appreciated.

    Thanks!

    Best,
    David

     
  • David Monarchi

    David Monarchi - 2013-10-14

    Hello all -

    I know I wrote the OP months ago, but I'm still stuck. I've updated to Tulip 4.3 and Python 2.7.5.

    I've read (and reread) the instructions under the heading "Using the bindings from the Python Interpreter" at
    http://tulip.labri.fr/Documentation/4_3/tulip-python/html/gettingstarted.html
    but cannot get any interpreter to import the Tulip bindings. I've tried both PyCharm and IPython.

    Has anyone been successful doing this? I'm at a dead end.

    Thanks!

    Best,
    David

    Addendum: 2013.10.15
    I realize I forgot to include the error message I get when trying to import Tulip. Perhaps this will be informative. Thanks.

    import tulip
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-3-ddc20e9424a5> in <module>()
    ----> 1 import tulip
    
    ImportError: DLL load failed: %1 is not a valid Win32 application.
    
     
    Last edit: David Monarchi 2013-10-15
  • Antoine Lambert

    Antoine Lambert - 2013-10-16

    Hi David,

    I just tried to import the tulip module from a fresh Tulip 4.3 install
    and it works fine for me (using classical Python shell, PyCharm or IPython).
    There is only one issue with Python IDLE (module can be imported but it overrides the standard output so nothing is displayed after, fixed in the latest Tulip source code on sourceforge).

    However the tulipogl and tulipgui module does not seem to work under windows (seems that they were linked against the wrong Python version, I don'k know why, I am not the person that builds the Tulip releases ...)

    Be sure that you are using the 32 bits version of the Python interpreter. One another possible reason of your issue is that your PATH variable contains the location of some DLLs Tulip depends on (for instance zlib or Qt4) but compiled for a different architecture (typically 64 bits instead of 32 bits).

    Try to issue the following commands in a cmd.exe
    C:...> set PATH=C:/Python27/:C:/Program Files (x86)/tulip/bin:%PATH% (assuming C:/Python27/ is the 32bits Python install directory)
    C:...> set PYTHONPATH=C:/Program Files (x86)/tulip/bin/python
    C:...> python

    from tulip import *

    If the module can be imported, it means that there is some DLL conflicts coming from the content of your PATH variable.

    Hope that it will help,

    Antoine

     
  • Adam Miller

    Adam Miller - 2013-10-16

    I helped Monarchi and I helped him find that he was using the wrong word size for the interpreter; the libraries and his interpreter were different 32/64 bit widths.

     
  • David Monarchi

    David Monarchi - 2013-10-18

    Hello all -

    Hello all -

    Adam was correct wrt 64 vs 32 bit versions of Python (thanks for the time you spent with me on this, Adam), but his insight did not solve the problem. The confusion was my fault. I was trying to do too many things at once on too many computers and had inadvertently tried to import Tulip into 64-bit Anaconda on one of them. Adam pointed out to me that this simply wouldn't work. (Yes, I felt a bit foolish afterwards... I actually knew better than to do this.)

    Just to be safe, I completely uninstalled Python, deleted all of the directories, etc., and then re-installed the 32-bit version of 2.7.5. I then went through the instructions Antoine posted (thank you, Antoine).

    The result is the same as before: DLL load failed: The specified module could not be found.

    As Antoine stated at the end of his post, perhaps some of the DLLs on which Tulip depends are from a different architecture. He listed two: zlib and Qt4. Is there a list of all of the dependencies somewhere, and can anyone tell me how I can determine whether the DLLs in question were compiled for 32-bit or 64-bit architecture?

    Thank you all very much for your patience.

    Best regards,
    David

     
  • David Monarchi

    David Monarchi - 2013-10-19

    Hello again -

    Following the advice I received from Antoine above and separately from Adam, I wrote a small PowerShell script and checked all of the dll and exe files in all of the subdirectories under Python27 and Tulip. All of them are 32-bit files.

    Does anyone have any suggestions? (Short of building a fresh machine dedicated to Tulip. :-) )

    Thanks again.

    Best,
    David

     
  • Adam Miller

    Adam Miller - 2013-10-19

    Oh I thought you it was resolved. Jump on IRC and hang out in there. Ping me when can, and I'll jump in there again sometime.

     
  • Olivier Deckers

    Olivier Deckers - 2013-10-29

    I managed to get it working by copying all the dll files in bin to bin/python

     
  • David Monarchi

    David Monarchi - 2013-11-08

    Thanks for the tip, Olivier. I followed your suggestion, and the tulip module is now found by Python (specifically, PyCharm). The error I'm getting now is

      the sip module implements API v8.0 but the tulip module requires API v9.0
    

    I downloaded sip 4.15.3, assuming it would contain the latest API implementation. And following a suggestion Adam gave me in an IRC conversation I downloaded and installed MinGW so I could execute the make command. MinGW seems to have installed fine, but make fails when used with the makefile in the sip-4.15.3 directory.

    Rather than pursue this approach any further, I thought I would download the latest version of PyQt for 2.7, which seems to be PyQt4-4.10.2-gpl-Py2.7-Qt4.8.4-x32, and install it. I assume that this would include the correct implementation of the API.

    If you have any suggestions, I would be grateful to get them.

    Again, thanks for the tip re copying the dll files!

    Best,
    David

     
  • David Monarchi

    David Monarchi - 2013-11-08

    I determined that I had PyQt4 4.8.1 installed, so I went ahead and installed PyQt4-4.10.2-gpl-Py2.7-Qt4.8.4-x32. The error changed to

       the sip module implements API v10.0 but the tulip module requires API v9.0
    

    so apparently the API implementations are not backward compatible or tulip is very picky.

    My next step was to uninstall the 4.10.2 version and install the 4.9.4 version (PyQt-Py2.7-x86-gpl-4.9.4-1) hoping that this would have API I need. After this installation, I was back to the original error

        the sip module implements API v8.0 to v8.1 but the tulip module requires API v9.0
    

    At this point my question is - does anyone know which version of PyQt4 I should install in order to have the correct API version?

    Thanks in advance for any assistance/advice.

    Best,
    David

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks