lucasb-eyer / pydensecrf

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

issue with installing. #60

Closed ranok92 closed 6 years ago

ranok92 commented 6 years ago

Hey, I tried to install the package. It installed properly. But when I tried to actually use it in python, this is what I am getting. Any idea why? I am using python 2.7. Also, I ran the setup.py file manually : python setup.py build_ext --inplace and I am using windows if that matters.

warning: pydensecrf\densecrf.pyx:20:4: Unreachable code

Error compiling Cython file:
------------------------------------------------------------
...
cimport eigen

cdef LabelCompatibility* _labelcomp(compat) except NULL:
    if isinstance(compat, Number):
        return new PottsCompatibility(compat)
                  ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:13:19: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...

cdef LabelCompatibility* _labelcomp(compat) except NULL:
    if isinstance(compat, Number):
        return new PottsCompatibility(compat)
    elif memoryview(compat).ndim == 1:
        return new DiagonalCompatibility(eigen.c_vectorXf(compat))
                  ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:15:19: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...
    if isinstance(compat, Number):
        return new PottsCompatibility(compat)
    elif memoryview(compat).ndim == 1:
        return new DiagonalCompatibility(eigen.c_vectorXf(compat))
    elif memoryview(compat).ndim == 2:
        return new MatrixCompatibility(eigen.c_matrixXf(compat))
                  ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:17:19: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...
        return ptr

    # It might already be deleted by the library, actually.
    # Yeah, pretty sure it is.
    def __dealloc__(self):
        del self.thisptr
       ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:36:8: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...
        del self.thisptr

cdef class ConstUnary(Unary):
    def __cinit__(self, float[:,::1] u not None):
        self.thisptr = new ConstUnaryEnergy(eigen.c_matrixXf(u))
                          ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:41:27: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...
        self.thisptr = new ConstUnaryEnergy(eigen.c_matrixXf(u))

cdef class LogisticUnary(Unary):
    def __cinit__(self, float[:,::1] L not None, float[:,::1] f not None):
        self.thisptr = new LogisticUnaryEnergy(eigen.c_matrixXf(L), eigen.c_matrixXf(f))
                          ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:46:27: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...
        # will always be called with the same params as the subclass, automatically.

        # We also only want to avoid creating an object if we're just being called
        # from a subclass as part of the hierarchy.
        if type(self) is DenseCRF:
            self._this = new c_DenseCRF(nvar, nlabels)
                            ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:58:29: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...

    def __dealloc__(self):
        # Because destructors are virtual, this is enough to delete any object
        # of child classes too.
        if self._this:
            del self._this
           ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:69:12: Operation only allowed in c++

Error compiling Cython file:
------------------------------------------------------------
...
cdef class DenseCRF2D(DenseCRF):

    # The same comments as in the superclass' `__cinit__` apply here.
    def __cinit__(self, int w, int h, int nlabels, *_, **__):
        if type(self) is DenseCRF2D:
            self._this = self._this2d = new c_DenseCRF2D(w, h, nlabels)
                                           ^
------------------------------------------------------------

pydensecrf\densecrf.pyx:109:44: Operation only allowed in c++
Traceback (most recent call last):

  File "<ipython-input-6-5cbb70704c71>", line 1, in <module>
    runfile('C:/Users/konar/ECSE DEEPMEDIC/pydensecrf/densecrf3d.py', wdir='C:/Users/konar/ECSE DEEPMEDIC/pydensecrf')

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/konar/ECSE DEEPMEDIC/pydensecrf/densecrf3d.py", line 7, in <module>
    import pydensecrf.densecrf as dcrf

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\pyximport\pyximport.py", line 458, in load_module
    language_level=self.language_level)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\pyximport\pyximport.py", line 233, in load_module
    exec("raise exc, None, tb", {'exc': exc, 'tb': tb})

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\pyximport\pyximport.py", line 215, in load_module
    inplace=build_inplace, language_level=language_level)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\pyximport\pyximport.py", line 191, in build_module
    reload_support=pyxargs.reload_support)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\pyximport\pyxbuild.py", line 102, in pyx_to_dll
    dist.run_commands()

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\site-packages\Cython\Distutils\old_build_ext.py", line 194, in build_extensions
    self.build_extension(ext)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\command\build_ext.py", line 499, in build_extension
    depends=ext.depends)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\msvc9compiler.py", line 473, in compile
    self.initialize()

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\msvc9compiler.py", line 383, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)

  File "C:\Users\konar\Anaconda3\envs\py27theano\lib\distutils\msvc9compiler.py", line 271, in query_vcvarsall
    raise DistutilsPlatformError("Unable to find vcvarsall.bat")

ImportError: Building module pydensecrf.densecrf failed: ['DistutilsPlatformError: Unable to find vcvarsall.bat\n']

Thanks, Abhisek

lucasb-eyer commented 6 years ago

Why did you decide to run python setup.py build_ext --inplace instead of just pip install .?

For some reason, it is trying to compile as C, not C++. When googling your error, I found people reporting it when they were using too old setuptools.

I'm afraid I cannot really help you any more as I'm not on Windows, but I'd definitely try installing it with pip.

PS: I edited your message to format it correctly by surrounding the output snippet by three backticks (````), please do so yourself in the future, your issue was completely unreadable!

ranok92 commented 6 years ago

I tried using pip install but the inline function round() in permutoheadral.cpp was throwing an error. So, I had to comment those lines and then run the setup. So, do you think I should try to update the setuptools or something?

On Sun, Apr 1, 2018 at 4:58 PM, Lucas Beyer notifications@github.com wrote:

Why did you decide to run python setup.py build_ext --inplace instead of just pip install .?

For some reason, it is trying to compile as C, not C++. When googling your error, I found people reporting it when they were using too old setuptools.

I'm afraid I cannot really help you any more as I'm not on Windows, but I'd definitely try installing it with pip.

PS: I edited your message to format it correctly by surrounding the output snippet by three backticks (````), please do so yourself in the future, your issue was completely unreadable!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/60#issuecomment-377816275, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2uVP_R06jGdepiHO3FfQuL4Lqfo0_ks5tkT-AgaJpZM4TC1IW .

lucasb-eyer commented 6 years ago

I have fixed the round issue as it was already reported in #44, seems to be a windows problem. I have also updated the version on PyPI, so you can try installing the latest version (1.0r3) again as pip install pydensecrf and see if it works.

If it still doesn't work, you can re-open this issue, although I will not have any new ideas to help you, I'm afraid!

ranok92 commented 6 years ago

Hey, so I tried to install in ubuntu 16.04 used pip, it installed properly, but when i use the import :

import pydensecrf.densecrf as dcrf

i get this error.

/home/abhisek/.local/lib/python2.7/site-packages/pydensecrf/densecrf.so: undefined symbol: PyFPE_jbuf

Any clue??

On Sun, Apr 1, 2018 at 6:54 PM, Lucas Beyer notifications@github.com wrote:

I have fixed the round issue as it was already reported in #44 https://github.com/lucasb-eyer/pydensecrf/issues/44, seems to be a windows problem. I have also updated the version on PyPI, so you can try installing the latest version again as pip install pydensecrf and see if it works.

If it still doesn't work, you can re-open this issue, although I will not have any new ideas to help you, I'm afraid!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/60#issuecomment-377823149, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2uXzESobQDghZpKoscFI19HDATMwMks5tkVrAgaJpZM4TC1IW .

ranok92 commented 6 years ago

Hey, I restarted my computer and tried again it seem to work now. Strange.

On Sun, Apr 1, 2018 at 10:09 PM, Abhisek Konar konarabhisek@gmail.com wrote:

Hey, so I tried to install in ubuntu 16.04 used pip, it installed properly, but when i use the import :

import pydensecrf.densecrf as dcrf

i get this error.

/home/abhisek/.local/lib/python2.7/site-packages/pydensecrf/densecrf.so: undefined symbol: PyFPE_jbuf

Any clue??

On Sun, Apr 1, 2018 at 6:54 PM, Lucas Beyer notifications@github.com wrote:

I have fixed the round issue as it was already reported in #44 https://github.com/lucasb-eyer/pydensecrf/issues/44, seems to be a windows problem. I have also updated the version on PyPI, so you can try installing the latest version again as pip install pydensecrf and see if it works.

If it still doesn't work, you can re-open this issue, although I will not have any new ideas to help you, I'm afraid!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/60#issuecomment-377823149, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2uXzESobQDghZpKoscFI19HDATMwMks5tkVrAgaJpZM4TC1IW .

ranok92 commented 6 years ago

Also, I was wondering if this has provisions to be extended to a 3D CRF?

On Mon, Apr 2, 2018 at 9:06 AM, Abhisek Konar konarabhisek@gmail.com wrote:

Hey, I restarted my computer and tried again it seem to work now. Strange.

On Sun, Apr 1, 2018 at 10:09 PM, Abhisek Konar konarabhisek@gmail.com wrote:

Hey, so I tried to install in ubuntu 16.04 used pip, it installed properly, but when i use the import :

import pydensecrf.densecrf as dcrf

i get this error.

/home/abhisek/.local/lib/python2.7/site-packages/pydensecrf/densecrf.so: undefined symbol: PyFPE_jbuf

Any clue??

On Sun, Apr 1, 2018 at 6:54 PM, Lucas Beyer notifications@github.com wrote:

I have fixed the round issue as it was already reported in #44 https://github.com/lucasb-eyer/pydensecrf/issues/44, seems to be a windows problem. I have also updated the version on PyPI, so you can try installing the latest version again as pip install pydensecrf and see if it works.

If it still doesn't work, you can re-open this issue, although I will not have any new ideas to help you, I'm afraid!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/60#issuecomment-377823149, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2uXzESobQDghZpKoscFI19HDATMwMks5tkVrAgaJpZM4TC1IW .

lucasb-eyer commented 6 years ago

Please keep issues on-topic and open a new issue for new problems.

Regarding your last question, please read the README file more carefully, there is a section about non-2D (and N-D) use.

ranok92 commented 6 years ago

Sorry. My bad. I will keep that in mind in future. Thanks for the info though. (Y)

On Mon, Apr 2, 2018 at 10:22 AM, Lucas Beyer notifications@github.com wrote:

Please keep issues on-topic and open a new issue for new problems.

Regarding your last question, please read the README file more carefully, there is a section about non-2D (and N-D) use.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/60#issuecomment-377939972, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2uZh1qd_9VY0VUTyEZQidPAdYpsuLks5tkjQxgaJpZM4TC1IW .