lucasb-eyer / pydensecrf

Python wrapper to Philipp Krähenbühl's dense (fully connected) CRFs with gaussian edge potentials.
MIT License
1.94k stars 414 forks source link

Package import problem #11

Closed pkorus closed 8 years ago

pkorus commented 8 years ago

I've successfully installed the library using:

pip install git+https://github.com/lucasb-eyer/pydensecrf.git

Now I've got 4 files in /usr/lib64/python2.7/site-packages/pydensecrf:

densecrf.so  eigen.so  utils.py  utils.pyc

However, I cannot import the library in Python. Both:

import pydensecrf.densecrf
import densecrf

are unsuccessful (/usr/lib64/python2.7/site-packages/ is in sys.path). If I explicitly append /usr/lib64/python2.7/site-packages/pydensecrf to sys.path, then Python can locate the densecrf library (import densecrf), but I get an import error:

ImportError: No module named pydensecrf.eigen

The problem has been observed under CentOS 7 and Debian Jessie.

lucasb-eyer commented 8 years ago

At first sight it seems like we're not installing the __init__.py file, which is a bug. I'll try to fix it over the weekend, but if anyone (@rodrigob maybe?) has an idea before that, I'd be grateful.

rshanor commented 8 years ago

I am currently having the same issue, after adding pydensecrf to the syspath I get a pydensecrf.eigen error as well.

rshanor commented 8 years ago

@pkorus did you ever find a workaround?

pkorus commented 8 years ago

In fact your first suggestion (adding __init__.py) did the trick for me.

rshanor commented 8 years ago

Just move that file into the folder? Thanks!

pkorus commented 8 years ago

Just to be clear - after installing the package through pip:

>> touch /usr/lib64/python2.7/site-packages/pydensecrf/__init__.py

And then you can import the package as import pydensecrf.densecrf

pkorus commented 8 years ago

Just to be clear - after installing the package through pip:

>> touch /usr/lib64/python2.7/site-packages/pydensecrf/__init__.py

And then you can import the package as import pydensecrf.densecrf

lucasb-eyer commented 8 years ago

Yeah exactly. The problem is that setup.py doesn't put it there, and I didn't get around to fixing that yet. PRs are welcome, otherwise I'll give it a go sometime in the next couple weeks.

rshanor commented 8 years ago

Awesome! Works for me too. Thanks guys.

lucasb-eyer commented 8 years ago

I think I fixed it, but it would be nice to have confirmation from someone. You can do pip uninstall pydensecrf and then install it again with pip as stated in the README.