whitphx / lear-gist-python

A python wrapper for Lear's GIST implementation working with numpy
MIT License
55 stars 14 forks source link

fftwf_plan_dft_2d undefined #25

Closed triyes closed 3 years ago

triyes commented 5 years ago

when import gist, ImportError occours like following: Traceback (most recent call last): File "", line 1, in ImportError: /usr/local/lib/python3.6/site-packages/gist.cpython-36m-x86_64-linux-gnu.so: undefined symbol: fftwf_plan_dft_2d Have you ever encountered this problem?

whitphx commented 5 years ago

Hello, I have never seen that error...

Now I ran the following commands in macOS Mojave (10.14.3) with Python 3.6.6 installed by pyenv then succeeded to build and use the library.

$ cd /tmp
$ wget http://www.fftw.org/fftw-3.3.8.tar.gz
$ tar xf fftw-3.3.8.tar.gz
$ cd fftw-3.3.8/
$ ./configure --enable-single --enable-shared
$ make
$ make install
$ git clone https://github.com/tuttieee/lear-gist-python.git
$ cd lear-gist-python
$ pyenv install 3.6.6
$ pyenv virtualenv 3.6.6 lear-gist-python3
$ pyenv local lear-gist-python3
$ pip install numpy
$ ./download-lear.sh
$ python setup.py build_ext
$ python setup.py install

Can you please tell me your environment (OS, python version, FFTW version, etc)?

triyes commented 5 years ago

I am sorry i am late. my environment as follow: CentOS Linux release 7.2 (Final) Python 3.6.1 fftw-3.3.8 What else do you need?

whitphx commented 5 years ago

I reproduced a similar situation ( ImportError: libfftw3f.so.3: cannot open shared object file: No such file or directory ) on the environment where

served as a docker container.

First, check if the library can be found

[root@7df039dd7832 lear-gist-python]# ldd /usr/local/lib64/python3.6/site-packages/gist.cpython-36m-x86_64-linux-gnu.so
        linux-vdso.so.1 =>  (0x00007ffe58dea000)
        libfftw3f.so.3 => not found
        libpython3.6m.so.1.0 => /lib64/libpython3.6m.so.1.0 (0x00007fa411f14000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa411cf8000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fa41192b000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fa411727000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007fa411524000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fa411222000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa412644000)

Here, yes, libfftw3f.so.3 is not found. (The path of the lib can be changed according to the environment. In this example, it is located in /usr/local/lib64/python3.6/site-packages )

To solve this, add a path where FFTW is installed to `:

$ export LD_LIBRARY_PATH=/usr/local/lib

Then, the gist module can be imported.

[root@7df039dd7832 lear-gist-python]# python3
Python 3.6.6 (default, Mar 29 2019, 00:03:27)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gist
>>>

You can find the path where FFTW is installed from the message of ./configure. When you execute ./configure --enable-single --enable-shared, a long output appears, which shows:

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

now you know where FFTW is installed and what to do 😄

AminTaheri23 commented 4 years ago

https://github.com/tuttieee/lear-gist-python/issues/25#issuecomment-490514753 this helped me, thank you 😊😊

Yahya-1997 commented 4 years ago

I am sorry i am late. my environment as follow: CentOS Linux release 7.2 (Final) Python 3.6.1 fftw-3.3.8 What else do you need?

I had the same issue. I tried all the answers on the internet with no use. Then I made a new environment in conda with python version 2.7 and install pyfftw3 and pyleargist. Solved my issue.