Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
121 views
in Technique[技术] by (71.8m points)

python - Cannot install pyfftw3 by pip

I am trying using FFTW3 in python and when I try to install it I got this:

xxxxxxx@iMac ~ % pip3 install pyfftw3      
Collecting pyfftw3
  Using cached PyFFTW3-0.2.1.tar.gz (25 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python@3.9/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-m021xxq5/pyfftw3_69a9370f7f41441eaca6ae508a6a1544/setup.py'"'"'; __file__='"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-m021xxq5/pyfftw3_69a9370f7f41441eaca6ae508a6a1544/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-pip-egg-info-m06gikf1
         cwd: /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-m021xxq5/pyfftw3_69a9370f7f41441eaca6ae508a6a1544/
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-m021xxq5/pyfftw3_69a9370f7f41441eaca6ae508a6a1544/setup.py", line 81
        print "build %s from template %s" %(outfile, tmplfile)
              ^
    SyntaxError: invalid syntax
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/58/07/e070b9a44429bbd5481f9f0b2d1b35d896fbfd180051e05c840186a31c8a/PyFFTW3-0.2.1.tar.gz#sha256=8941a023e6e4f501e7cec92382c3d3f76f47c7583e9eade738840dd9e4e467c4 (from https://pypi.org/simple/pyfftw3/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement pyfftw3
ERROR: No matching distribution found for pyfftw3

I have the newest version of python installed by Homebrew. Pip is also the newest version. I have tried pip install -U setuptools


Inspired by 'Swetank Poddar': I found the pyfftw3 is a python2 library, so I tried pip3 install pyfftw. But, I got a new question:

Collecting pyfftw
  Downloading pyFFTW-0.12.0.tar.gz (137 kB)
     |████████████████████████████████| 137 kB 167 kB/s 
Requirement already satisfied: numpy<2.0,>=1.10 in /usr/local/lib/python3.9/site-packages (from pyfftw) (1.19.5)
Building wheels for collected packages: pyfftw
  Building wheel for pyfftw (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/setup.py'"'"'; __file__='"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-wheel-e51wsh5k
       cwd: /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.15-x86_64-3.9
  creating build/lib.macosx-10.15-x86_64-3.9/pyfftw
  copying pyfftw/config.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw
  copying pyfftw/_version.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw
  copying pyfftw/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw
  creating build/lib.macosx-10.15-x86_64-3.9/pyfftw/builders
  copying pyfftw/builders/builders.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/builders
  copying pyfftw/builders/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/builders
  copying pyfftw/builders/_utils.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/builders
  creating build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/cache.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/scipy_fft.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/dask_fft.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/numpy_fft.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/scipy_fftpack.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  copying pyfftw/interfaces/_utils.py -> build/lib.macosx-10.15-x86_64-3.9/pyfftw/interfaces
  UPDATING build/lib.macosx-10.15-x86_64-3.9/pyfftw/_version.py
  set build/lib.macosx-10.15-x86_64-3.9/pyfftw/_version.py to '0.12.0'
  running build_ext
  error: Could not find any of the FFTW libraries
  ----------------------------------------
  ERROR: Failed building wheel for pyfftw
  Running setup.py clean for pyfftw
Failed to build pyfftw
Installing collected packages: pyfftw
    Running setup.py install for pyfftw ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/setup.py'"'"'; __file__='"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-record-ljyxfo00/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/include/python3.9/pyfftw
         cwd: /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/
    Complete output (7 lines):
    running install
    running build
    running build_py
    UPDATING build/lib.macosx-10.15-x86_64-3.9/pyfftw/_version.py
    set build/lib.macosx-10.15-x86_64-3.9/pyfftw/_version.py to '0.12.0'
    running build_ext
    error: Could not find any of the FFTW libraries
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/setup.py'"'"'; __file__='"'"'/private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-install-p3twpksg/pyfftw_a5a93b1d21cd45bb90489634e47c82a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/xc/vzy2gb2j2hs8tyv7j70d979h0000gn/T/pip-record-ljyxfo00/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/include/python3.9/pyfftw Check the logs for full command output.

It looks like the problem is mainly about the "Building wheel for pyfftw".

question from:https://stackoverflow.com/questions/65920494/cannot-install-pyfftw3-by-pip

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Alternatively you could install pyFFTW: pip install pyFFTW

Install instructions for Mac OS:
Install FFTW from homebrew:

brew install fftw

Set temporary environmental variables, such that pyfftw finds fftw:

export DYLD_LIBRARY_PATH=/usr/local/lib export LDFLAGS="-L/usr/local/lib"
export CFLAGS="-I/usr/local/include"

Now install pyfftw from pip:

pip install pyfftw

It has been suggested that macports might also work fine. You should then replace the LD environmental variables above with the right ones.

  • DYLD - path for libfftw3.dylib etc - find /usr -name libfftw3.dylib
  • LDFLAGS - path for fftw3.h - find /usr -name fftw3.h

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...