eggplantbren / DNest4

Diffusive Nested Sampling
MIT License
62 stars 22 forks source link

Getting Cython-related error when running Python sampler #17

Closed eggplantbren closed 5 years ago

eggplantbren commented 7 years ago

Hi Dan,

Am I doing something stupid? Was just trying to run the gaussian.py example and it's complaining that I didn't build the Cython extensions, even though I did.

python gaussian.py Traceback (most recent call last): File "gaussian.py", line 43, in <module> sep=" ")) File "/home/brendon/local/anaconda3/lib/python3.5/site-packages/dnest4-0.1.4-py3.5-linux-x86_64.egg/dnest4/sampler.py", line 17, in __init__ raise ImportError("You must build the Cython extensions to use " ImportError: You must build the Cython extensions to use the Python API

eggplantbren commented 7 years ago

I'm using Anaconda 4.2.0 on Ubuntu 16.10, and the DNest python package was successfully installed with python setup.py install. Let me know what other info might help...

MichelleLochner commented 7 years ago

@eggplantbren I had the same problem with anaconda. It turns out to be a mismatch between the compiler used to compile DNest4 and the compiler used by anaconda when running cythonize. I did the following (after making DNest4):

export CC=/usr/bin/gcc export CXX=/usr/bin/g++ python setup.py install

I'm not sure if setting both compilers is necessary or just the C++ one but after this it worked.

eggplantbren commented 7 years ago

I'm glad this worked for you, but it didn't for me...😕

eggplantbren commented 6 years ago

This was a strange issue with my setup that seems to have been resolved. Closing

eggplantbren commented 5 years ago

This is happening again on two separate fresh installs of Anaconda 5.3.1 for Linux. I have no clue why - I have Cython and I saw it compiling when I installed the package. I've also tried Michelle's suggestion, which didn't help. Let me know of anything that might diagnose this, @dfm. It's a fairly severe problem if this happens to a user.

dfm commented 5 years ago

This normally has to do with trying to run within the directory where the package is installed. It can help to use: python setup.py develop instead of install. You might also try running pip uninstall dnest4 a few times first. Hope this helps!

eggplantbren commented 5 years ago

I just tried all of those suggestions and none of them worked.

dfm commented 5 years ago

What happens when you run:

from dnest4._dnest4 import sample

from Python?

eggplantbren commented 5 years ago

I wasn't expecting this, but it seems like a clue!

Python 3.7.0 (default, Oct  9 2018, 10:31:47) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dnest4
>>> from dnest4._dnest4 import sample
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/brewer/local/anaconda3/lib/python3.7/site-packages/dnest4-0.2.3-py3.7-linux-x86_64.egg/dnest4/_dnest4.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6DNest46CauchyC1Edd
dfm commented 5 years ago

Looks like there might be new files that need to be included. Take a look at setup.py in the Python directory and see which files are missing? I'm not sure where Cauchy is defined.

eggplantbren commented 5 years ago

That was exactly it. I just didn't know I had to edit setup.py after adding more features in the C++, but now I do. Thanks heaps. Closed with commit b76065322733a48a34eeca32ade23f3d2750df3c

dfm commented 5 years ago

Excellent.