Intel® Distribution for Python*
Engage in discussions with community peers related to Python* applications and core computational packages.
413 Discussions

ImportError: cannot import name fft_ on OSX (Python+MKL)

John_O_
Beginner
1,400 Views

I installed MKL and the Intel Python Distribution for OSX and I'm having trouble importing scipy.signal:

$ python
Python 2.7.12 |Intel Corporation| (default, Feb  5 2017, 00:31:58) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import scipy.signal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/scipy/signal/__init__.py", line 298, in <module>
    from .windows import *
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/scipy/signal/windows.py", line 7, in <module>
    from scipy import fftpack, linalg, special
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/scipy/fftpack/__init__.py", line 98, in <module>
    from numpy.fft import fft_   as fft
ImportError: cannot import name fft_

I get a similar failure when I run scipy.test():

$ python
Python 2.7.12 |Intel Corporation| (default, Feb  5 2017, 00:31:58) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import scipy
>>> scipy.test()
Running unit tests for scipy
NumPy version 1.12.1
NumPy relaxed strides checking option: True
NumPy is installed in /opt/intel/intelpython27/lib/python2.7/site-packages/numpy
SciPy version 0.18.1
SciPy is installed in /opt/intel/intelpython27/lib/python2.7/site-packages/scipy
Python version 2.7.12 |Intel Corporation| (default, Feb  5 2017, 00:31:58) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
nose version 1.3.7
[snip]
ERROR: Failure: ImportError (cannot import name fft_)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/opt/intel/intelpython27/lib/python2.7/site-packages/scipy/fftpack/__init__.py", line 98, in <module>
    from numpy.fft import fft_   as fft
ImportError: cannot import name fft_
[snip]
----------------------------------------------------------------------
Ran 22144 tests in 515.705s

FAILED (KNOWNFAIL=59, SKIP=1834, errors=3, failures=3)
<nose.result.TextTestResult run=22144 errors=3 failures=3>

I assume I made a mistake during my install.  I would appreciate any guidance.  Thanks in advance.

0 Kudos
11 Replies
Oleksandr_P_Intel
1,400 Views

Hi John, 

I was attempting to recreate the problem you experience as follows:

# install Miniconda3 downloaded with curl -O https://repo.continuum.io/miniconda/Miniconda3-4.2.12-MacOSX-x86_64.sh
./Miniconda3-4.2.12-MacOSX-x86_64.sh
# activate
source ./miniconda3/bin/activate
# create environment
conda create --name idp_2017u2_py2 -c intel python=2 intelpython2_core --yes
# activate it
source activate idp_2017u2_py2

With this setup I can not reproduce the problem: 

# try to reproduce
(idp_2017u2_py2) [20:40:25 fxsatmac02 opavlyk]$ python
Python 2.7.12 |Intel Corporation| (default, Feb  5 2017, 00:31:58)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import scipy.signal
>>> exit()

Did you download the distribution as an installer from registrationcenter.intel.com?

Perhaps the method I tried could be used as a work-around. I will try to reproduce the issue using the installer.

Best regards, Oleksandr

0 Kudos
gaston-hillar
Black Belt
1,400 Views

Hi John,

If you run the following commands in a Terminal window on macOS, do you see any results?

conda list | grep scipy
conda list | grep mkl
0 Kudos
Oleksandr_P_Intel
1,400 Views

Please try running

python -c "import numpy.fft as m; print dir(m)"

This what I get by running this line:

(idp_2017u2_py2) [21:18:02 fxsatmac02 opavlyk]$ python -c "import numpy.fft as m; print dir(m)"
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_numpy_tester', 
'absolute_import', 'bench', 'division', 'fft', 'fft2', 'fft2_', 'fft_', 'fftfreq', 'fftn', 'fftn_', 
'fftshift', 'helper', 'hfft', 'ifft', 'ifft2', 'ifft2_', 'ifft_', 'ifftn', 'ifftn_', 'ifftshift', 
'ihfft', 'info', 'irfft', 'irfft2', 'irfftn', 'print_function', 'rfft', 'rfft2', 'rfftfreq', 'rfftn', 'test']

It would also be useful if you included the full output of 

/opt/intel/intelpython27/bin/conda list --explicit

Thank you,
Oleksandr

0 Kudos
John_O_
Beginner
1,400 Views

Here you go Gastón:

(root) mini:tmp john$ conda list | grep scipy
scipy                     0.18.1          np111py27_intel_10  [intel]  intel
(root) mini:tmp john$ conda list | grep mkl
mkl                       2017.0.2                intel_1  [intel]  intel

And for you Oleksandr:

(root) mini:tmp john$ python -c "import numpy.fft as m; print dir(m)"
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_numpy_tester', 'absolute_import', 'bench', 'division', 'fft', 'fft2', 'fftfreq', 'fftn', 'fftpack', 'fftpack_lite', 'fftshift', 'helper', 'hfft', 'ifft', 'ifft2', 'ifftn', 'ifftshift', 'ihfft', 'info', 'irfft', 'irfft2', 'irfftn', 'print_function', 'rfft', 'rfft2', 'rfftfreq', 'rfftn', 'test']
(root) mini:tmp john$ /opt/intel/intelpython27/bin/conda list --explicit
# This file may be used to create an environment using:
# $ conda create --name --file
# platform: osx-64
@EXPLICIT
https://conda.anaconda.org/intel/osx-64/appnope-0.1.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/backports-1.0-py27_intel_6.tar.bz2
https://conda.anaconda.org/intel/osx-64/backports_abc-0.4-py27_intel_7.tar.bz2
https://conda.anaconda.org/intel/osx-64/conda-4.2.12-py27_intel_0.tar.bz2
https://conda.anaconda.org/intel/osx-64/conda-env-2.6.0-0.tar.bz2
https://conda.anaconda.org/intel/osx-64/configparser-3.5.0-py27_intel_3.tar.bz2
https://conda.anaconda.org/intel/osx-64/cycler-0.10.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/cython-0.24-py27_intel_16.tar.bz2
https://conda.anaconda.org/intel/osx-64/decorator-4.0.10-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/entrypoints-0.2.2-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/enum34-1.1.6-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/freetype-2.5.5-intel_9.tar.bz2
https://conda.anaconda.org/intel/osx-64/funcsigs-1.0.2-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/functools32-3.2.3.2-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/get_terminal_size-1.0.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/hdf5-1.8.17-intel_0.tar.bz2
https://conda.anaconda.org/intel/osx-64/icc_rt-16.0.3-intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/intelpython-2017.0.2-0.tar.bz2
https://conda.anaconda.org/intel/osx-64/ipykernel-4.5.0-py27_intel_4.tar.bz2
https://conda.anaconda.org/intel/osx-64/ipython-4.2.0-py27_intel_8.tar.bz2
https://conda.anaconda.org/intel/osx-64/ipython_genutils-0.1.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/ipywidgets-5.2.2-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/jinja2-2.8-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/jsonschema-2.5.1-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/jupyter-1.0.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/jupyter_client-4.4.0-py27_intel_2.tar.bz2
https://conda.anaconda.org/intel/osx-64/jupyter_console-5.0.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/jupyter_core-4.2.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/libpng-1.6.28-intel_10.tar.bz2
https://conda.anaconda.org/intel/osx-64/llvmlite-0.15.0-py27_intel_0.tar.bz2
https://conda.anaconda.org/intel/osx-64/markupsafe-0.23-py27_intel_6.tar.bz2
https://conda.anaconda.org/intel/osx-64/matplotlib-1.5.3-py27_intel_3.tar.bz2
https://conda.anaconda.org/intel/osx-64/mistune-0.7.3-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/mkl-2017.0.2-intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/mpmath-0.19-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/nbconvert-4.2.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/nbformat-4.1.0-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/nose-1.3.7-py27_intel_12.tar.bz2
https://conda.anaconda.org/intel/osx-64/notebook-4.2.3-py27_intel_7.tar.bz2
https://conda.anaconda.org/intel/osx-64/numba-0.30.1-py27_intel_11.tar.bz2
https://conda.anaconda.org/intel/osx-64/numexpr-2.6.1-np111py27_intel_11.tar.bz2
https://conda.anaconda.org/intel/osx-64/numpy-1.11.2-py27_intel_51.tar.bz2
https://conda.anaconda.org/intel/osx-64/openssl-1.0.2k-intel_3.tar.bz2
https://conda.anaconda.org/intel/osx-64/pandas-0.19.2-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/path.py-8.2.1-py27_intel_7.tar.bz2
https://conda.anaconda.org/intel/osx-64/pathlib2-2.1.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/pexpect-4.0.1-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/pickleshare-0.7.4-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/pip-8.1.2-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/prompt_toolkit-1.0.3-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/ptyprocess-0.5.1-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/pycosat-0.6.1-py27_intel_6.tar.bz2
https://conda.anaconda.org/intel/osx-64/pydaal-2017.0.2.20170126-py27_intel_0.tar.bz2
https://conda.anaconda.org/intel/osx-64/pygments-2.1.3-py27_intel_6.tar.bz2
https://conda.anaconda.org/intel/osx-64/pyparsing-2.1.4-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/pytables-3.2.3.1-py27_intel_8.tar.bz2
https://conda.anaconda.org/intel/osx-64/python-2.7.12-intel_20.tar.bz2
https://conda.anaconda.org/intel/osx-64/python-dateutil-2.5.3-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/pytz-2016.6.1-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/pyzmq-15.4.0-py27_intel_3.tar.bz2
https://conda.anaconda.org/intel/osx-64/requests-2.11.1-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/ruamel_yaml-0.11.14-py27_intel_1.tar.bz2
https://conda.anaconda.org/intel/osx-64/scikit-learn-0.18.1-py27_intel_4.tar.bz2
https://conda.anaconda.org/intel/osx-64/scipy-0.18.1-np111py27_intel_10.tar.bz2
https://conda.anaconda.org/intel/osx-64/setuptools-23.0.0-py27_intel_4.tar.bz2
https://conda.anaconda.org/intel/osx-64/simplegeneric-0.8.1-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/singledispatch-3.4.0.3-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/six-1.10.0-py27_intel_7.tar.bz2
https://conda.anaconda.org/intel/osx-64/sqlite-3.13.0-intel_13.tar.bz2
https://conda.anaconda.org/intel/osx-64/ssl_match_hostname-3.5.0.1-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/sympy-1.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/tbb-2017.0.4-py27_intel_0.tar.bz2
https://conda.anaconda.org/intel/osx-64/tcl-8.6.4-intel_16.tar.bz2
https://conda.anaconda.org/intel/osx-64/terminado-0.6-py27_intel_6.tar.bz2
https://conda.anaconda.org/intel/osx-64/tk-8.6.4-intel_18.tar.bz2
https://conda.anaconda.org/intel/osx-64/tornado-4.4.1-py27_intel_3.tar.bz2
https://conda.anaconda.org/intel/osx-64/traitlets-4.2.2-py27_intel_3.tar.bz2
https://conda.anaconda.org/intel/osx-64/wcwidth-0.1.7-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/wheel-0.29.0-py27_intel_5.tar.bz2
https://conda.anaconda.org/intel/osx-64/widgetsnbextension-1.2.6-py27_0.tar.bz2
https://conda.anaconda.org/intel/osx-64/yaml-0.1.6-intel_10.tar.bz2
https://conda.anaconda.org/intel/osx-64/zlib-1.2.11-intel_0.tar.bz2

Let me know if you have any other commands to try. In a few hours, I'll uninstall and reinstall per Oleksandr's original reply. Thank you for your assistance!

0 Kudos
gaston-hillar
Black Belt
1,400 Views

Hi John,

It seems to me you have everything that is needed. I'm working with 2017 Update 2 on macOS El Capitan, formerly known as OS X El Capitan.

0 Kudos
Oleksandr_P_Intel
1,400 Views

John, 

I copy-pasted the output of your run of `conda list --explicit`, commented out two entries about conda and conda-env  (lines 4 and 5) after the line `@EXPLICIT`, saved the file into `john_env.txt`, and then ran

conda create --name john --file john_env.txt

This recreated your environment as conda thought it was. Even here the problem could not reproduced:

(root) [14:29:34 fxsatmac02 opavlyk]$ . activate john
(john) [14:29:59 fxsatmac02 opavlyk]$ python -c "import numpy.fft as m; print dir(m)"
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 
'_numpy_tester', 'absolute_import', 'bench', 'division', 'fft', 'fft2', 'fft2_', 
'fft_', 'fftfreq', 'fftn', 'fftn_', 'fftshift', 'helper', 'hfft', 'ifft', 'ifft2', 
'ifft2_', 'ifft_', 'ifftn', 'ifftn_', 'ifftshift', 'ihfft', 'info', 'irfft', 
'irfft2', 'irfftn', 'print_function', 'rfft', 'rfft2', 'rfftfreq', 'rfftn', 'test']

It is best to reinstall the distribution to see if the problem fixes itself.

0 Kudos
John_O_
Beginner
1,400 Views

I reinstalled using Oleksandr instructions and importing scipy.signal works fine, but when I try to run my production code, an import cv2 fails.  I tried installing via "conda install opencv-python" but I get a PackageNotFoundError, so I used "pip install opencv-python".  That works but it reinstalls numpy and my problem reappears!

(idp_2017u2_py2) mini:registrar john$ conda install opencv-python
PackageNotFoundError: Package not found: '' Package missing in current osx-64 channels: 
  - opencv-python
(idp_2017u2_py2) mini:registrar john$ pip install opencv-python
Installing collected packages: numpy, opencv-python
  Found existing installation: numpy 1.11.2
    Uninstalling numpy-1.11.2:
      Successfully uninstalled numpy-1.11.2
Successfully installed numpy-1.12.1 opencv-python-3.2.0.6

(idp_2017u2_py2) mini:registrar john$ python
Python 2.7.12 |Intel Corporation| (default, Feb  5 2017, 00:31:58) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import scipy.signal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/john/miniconda3/envs/idp_2017u2_py2/lib/python2.7/site-packages/scipy/signal/__init__.py", line 298, in <module>
    from .windows import *
  File "/Users/john/miniconda3/envs/idp_2017u2_py2/lib/python2.7/site-packages/scipy/signal/windows.py", line 7, in <module>
    from scipy import fftpack, linalg, special
  File "/Users/john/miniconda3/envs/idp_2017u2_py2/lib/python2.7/site-packages/scipy/fftpack/__init__.py", line 98, in <module>
    from numpy.fft import fft_   as fft
ImportError: cannot import name fft_

0 Kudos
John_O_
Beginner
1,400 Views

I could not use conda to install opencv because that version of opencv depends on numpy 1.7 so I ended up using "conda install opencv -c conda-forge".  I'm making progress again, but if there is a better way to get opencv with Intel Python, please let me know.  Thanks.

0 Kudos
Oleksandr_P_Intel
1,400 Views

John Otken wrote:

I could not use conda to install opencv because that version of opencv depends on numpy 1.7 so I ended up using "conda install opencv -c conda-forge".  I'm making progress again, but if there is a better way to get opencv with Intel Python, please let me know.  Thanks.

I just tried installing opencv into Intel Distribution for Python3, got the instructions on StackOverflow

(idp_2017u2) [15:39:32 fxsatlin04 opavlyk]$ conda install -c https://conda.binstar.org/menpo opencv
Fetching package metadata .........
Solving package specifications: ..........

Package plan for installation in environment /localdisk/work/opavlyk/miniconda3/envs/idp_2017u2:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    opencv-3.1.0               |      np111py35_1        36.5 MB

The following NEW packages will be INSTALLED:

    opencv: 3.1.0-np111py35_1

Proceed (/n)?

which appeared to work fine. I have not found opencv for Python 2 yet.

0 Kudos
John_O_
Beginner
1,400 Views

I'm currently using Python 2.7.  When I installed using conde-forge, it displays:

opencv:      3.2.0-np111py27_blas_openblas_200 conda-forge [blas_openblas]

I assume that means opencv is using the non-optimal BLAS library as opposed to MKL.

0 Kudos
gaston-hillar
Black Belt
1,400 Views

Hi John,

The initial problem you mentioned in this thread has been solved by reinstalling. So, this thread is solved. Now, you are trying to install a different package to run your code. When this happens, instead of adding additional questions on the same thread, it is a good idea to open another thread with the specific problem / question. This way, the forum has a better organization.

I'm not working with opencv on Pyton 2.7 on macOS. So, I won't be able to help you with your new question. It's great to know the first issue is solved.

0 Kudos
Reply