skieffer / hola

Human-like Orthogonal Layout Algorithm
46 stars 10 forks source link

ImportError: No module named _adaptagrams #5

Closed andrewh closed 8 years ago

andrewh commented 8 years ago

Hi, thanks for making HOLA available. I'm having a problem getting started:

$ ./hola_basic < orthogonal1.gml > orth_hola.gml
Traceback (most recent call last):
  File "./hola_basic", line 5, in <module>
    from hola.hola import hola
  File "/Users/andrewh/Projects/Metagram/research/hola/hola/hola/hola.py", line 30, in <module>
    import adaptagrams.adaptagrams as adg
  File "/Users/andrewh/Projects/Metagram/research/hola/hola/adaptagrams/adaptagrams.py", line 21, in <module>
    _adaptagrams = swig_import_helper()
  File "/Users/andrewh/Projects/Metagram/research/hola/hola/adaptagrams/adaptagrams.py", line 20, in swig_import_helper
    return importlib.import_module('_adaptagrams')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _adaptagrams

In the same directory I have a symlink from adaptagrams to ../adapaca/cola, and I have build Adapaca from the build instructions, using autogen.sh and make -f Makefile-swig-python to generate the adaptagrams.py file.

I'm on Mac OSX 10.11.6, and have used swig 3.0.10 from homebrew.

In the README the instructions say:

$ cd ADAPDIR/cola
$ touch __init__.py
$ cd HOLADIR/main
$ ln -s ADAPDIR/cola adaptagrams

But no main directory exists. Do you mean hola? If so, I will submit a PR to update the README.

I did try the symlink in the hola directory but got the same error.

Thanks in advance for any help.

skieffer commented 8 years ago

Oops, the symlink should actually be created in HOLADIR. I've fixed the README. Thanks for pointing this out -- don't know how it was missed up to now.

However, I'm not sure this will help you since you say you had a symlink "In the same directory". Do you mean you tried making the symlink in HOLADIR? That's where it should be, so if it is not working I will have to think more about this. Please send a reply saying whether this solves your problem.

andrewh commented 8 years ago

Sorry, I meant that I created the symlink in HOLADIR, the same directory as hola_basic. The error seems to be in adaptagrams.py, where it tries to import a module named _adaptagrams, but none exists. Not sure if this means I should create an issue on Adapaca? Happy to do so.

skieffer commented 8 years ago

This sounds like either the C++ build or the SWIG step didn't work. Unfortunately I cannot help with these steps as much as I could with any issues relating to the HOLA library itself, but I will try. In ADAPDIR/cola do you have the file _adaptagrams.so? Should be large, about 7.2M.

andrewh commented 8 years ago

Thanks for the reply. I have _adaptagrams.cpython-35m-darwin.so in ADAPDIR/cola. I tried symlinking it to _adaptagrams.so but it gave the same error.

skieffer commented 8 years ago

Hi, and sorry for the delay. I'm afraid the best advice I can offer with this is to try building the proper Adaptagrams library itself, and see if you get a usable adaptagrams.py. (It won't work with HOLA, but you can try importing it in Python and see if that works.) This would tend to indicate whether the problem is with your build system or with the experimental Adapaca library (I suspect the latter). I'll close the issue here and ask you to reopen it in the Adapaca repo, as you suggested doing earlier. Cheers

antonaut commented 7 years ago

Just in case somebody looks here;

I had the same problem. I had an anaconda environment making my python a python 3.5. Figured out from building adaptagrams itself, that you can build _adaptagrams.so by running (in ADAPDIR):

 python2.7 swig-python-setup.py build_ext --inplace

It worked fine for adapaca as well.