Search code examples
pythonpython-3.xnumpypydev

ImportError for fftconvolve in PyDev


Using the following code

import numpy as np
from scipy.signal import fftconvolve
import matplotlib.pyplot as plt

gives the following stack trace

Traceback (most recent call last):
  File "/Users/Erik/Documents/workspace- 
python/src/pywavelets/Problem1/Problem1.py", line 8, in <module>
    from scipy.signal import fftconvolve
  File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/signal/__init__.py", line 311, in <module>
    from . import sigtools, windows
  File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/signal/windows/__init__.py", line 40, in <module>
    from .windows import *
  File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/signal/windows/windows.py", line 9, in <module>
    from scipy import fftpack, linalg, special
  File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/fftpack/__init__.py", line 99, in <module>
    from .basic import *
  File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/fftpack/basic.py", line 12, in <module>
    from . import _fftpack
ImportError: 
dlopen(/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so, 2): Symbol not 
found: _main
  Referenced from: 
/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so
  Expected in: flat namespace
 in /Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site- 
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so

I've tried reinstalling numpy and scipy using pip, but didn't do anything.

Perhaps I need to specify some library in PYTHONPATH? I've read elsewhere that PyDev should automatically detect necessary imports, and numpy and tensorflow seem to work fine without any outside directories specified.

I do know that the error is specific to PyDev, since the code executes fine in the console.

Can anyone help me pinpoint the problem? Thank you!


Solution

  • If it works in the console an not in PyDev, please check if your environment variables are the same in both cases.

    i.e.:

    for key, val in sorted(os.environ.items()):
        print('%s=%s' % (key, val))
    

    Run both and save the output in different files and then compare to see what's different. The most likely culprits are LD_LIBRARY_PATH, PATH and PYTHONPATH...

    One thing to check is running Eclipse from the same console where you got things running (as it should inherit those variables).