thaines/helit

help needed -- just getting started

Opened this issue · 3 comments

Hello. I would very much like to try out "My text in your handwriting." I am following the instructions, utilizing Ubuntu 18.04 (on WSL2 in Windows10, but I don't think that should make a difference). I am using Python 2.7. I have scipy and numpy installed. But when I try to run one of the test python files in the frf directory (as suggested in the instructions, to test that the first of the two compiling methods is working), I get the following error, no matter which file I run.

(venv) scott@Yogi:~/envs/helit/frf$ python test_weight.py
Traceback (most recent call last):
  File "test_weight.py", line 13, in <module>
    import frf
  File "/home/scott/envs/helit/frf/frf.py", line 23, in <module>
    from frf_c import *
ImportError: /home/scott/envs/helit/frf/frf_c.so: undefined symbol: SummaryPtr

(And among possible problems mentioned in the instructions: I already have gcc installed; and I have the python-dev version installed; however, I do not have a dev version of numpy installed since I don't really understand what that is or how to install it. I just have "regular" numpy installed, I guess.)

I sure hope someone can please help me out! (It doesn't look like there's been much activity here for a while.) Thank you.

This is old code, and unmaintained I'm afraid, so it's going to be quite challenging to get it working!

SummaryPtr is an inline function defined on line 876 of summary.c inside the frf directory - that it now seems to be picked up as an undefined symbol suggests something has changed with the compiler/how it's setup between when i wrote this code and now, presumably at the level of Python's default compilation parameters. It's just a convenience wrapper really - does almost nothing, hence being defined inline, so you could just go to line 876 and remove the word inline at the start - would almost certainly fix it. But as an educated guess this is probably a C99 vs GNU difference, and the correct fix is to add the word static at the start, so line 876 looks like:

static inline Summary SummaryPtr(SummarySet * this, int i)

if you could try that and confirm if it works or not that would be great!

You will need numpy-dev installed I'm afraid, eventually, but shouldn't be any harder to install than python-dev as should just be in your package manager.

Thank you so much for your reply!

I made the change on line 876 of summary.c and it didn't give me the error! And, as I figured might happen, it gave me a new but similar one:

ImportError: /home/scott/envs/helit/frf/frf_c.so: undefined symbol: CodePtr

So I added static on line 871 of summary.c, as well.

Then I got:

(venv) scott@Yogi:~/envs/helit/frf$ python test_continuous_to_continuous.py
____________________________________________________________
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Done - 2.07140612602 seconds

Made forest (oob = 0.0635):
  Tree 0: 76588 bytes, 2320 nodes
  Tree 1: 76652 bytes, 2322 nodes
  Tree 2: 77248 bytes, 2340 nodes
  Tree 3: 75664 bytes, 2292 nodes

Test average error:
[0.02847912 0.03589108] (0.0458)

Test error:
0.0464

Is that success?

About trying to install numpy-dev:

Ubuntu 18.04 ships with python3. So I'm working in a virtualenv with python2.7. Also, I'm a novice in Linux, so by package manager, I'm not sure if you mean something like a desktop-type, gui thing (which I don't have at present -- I'm just using a terminal) or something else (like using pip within my virtualenv).

Anyways, I tried the following within my virtualenv, but all of them gave ERROR: No matching distribution found:

pip install numpy-dev
pip install python-numpy-dev
pip install py-numpy-dev

Outside my virtualenv, running sudo apt-get install -y python-numpy-dev did something. But then I saw this in the output: Note, selecting 'python-numpy' instead of 'python-numpy-dev'

  1. Do you happen to know the spelled-out instructions for adding numpy-dev?
  2. Do you know how to check within my virtualenv whether or not I have the proper python-dev and numpy-dev?

I know I'm necroposting and late to the game but I'm also trying to get this compiling/working and have the same problem @SB2020-eye seems to: I can't find a 'numpy-dev' or 'python-numpy-dev'; at least, not for Ubuntu. Google searching for them returns pretty nebulous results too .. some scan references but that's it.

@thaines: If you have a moment, any chance you might shed a bit of light on what distro and versions of numpy, scipy, buildessentials/make, et all you were using at the time? Otherwise I'll just start guessing based on the early 2016 time frame.