1

我正在尝试在 python 中使用 FFTW3,当我尝试安装它时,我得到了这个:

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('"'"'\r\n'"'"', '"'"'\n'"'"');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

我有 Homebrew 安装的最新版本的 python。Pip 也是最新版本。我努力了pip install -U setuptools


受到“Swetank Poddar”的启发:我发现它pyfftw3是一个 python2 库,所以我尝试了pip3 install pyfftw. 但是,我有一个新问题:

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('"'"'\r\n'"'"', '"'"'\n'"'"');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('"'"'\r\n'"'"', '"'"'\n'"'"');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('"'"'\r\n'"'"', '"'"'\n'"'"');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.

看起来问题主要是关于“pyfftw的构建轮”。

4

3 回答 3

1

或者,您可以安装pyFFTWpip install pyFFTW

Mac OS 的安装说明
从 homebrew 安装 FFTW:

brew install fftw

设置临时环境变量,以便 pyfftw 找到 fftw:

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

现在从 pip 安装 pyfftw:

pip install pyfftw

有人建议 macports 也可以正常工作。然后,您应该用正确的替换上面的 LD 环境变量。

  • DYLD - libfftw3.dylib 等的路径 - 查找 /usr -name libfftw3.dylib
  • LDFLAGS - fftw3.h 的路径 - 查找 /usr -name fftw3.h
于 2021-01-27T13:58:50.300 回答
0

通过键入python --version检查一次 python 版本,如果它是最新版本的 python,请转到您正在键入的代码并检查 print 语句,因为它在命令提示符中显示错误,如您所提到的...在最新版本的python你必须在print之后使用括号(“你必须使用括号”)

于 2021-01-27T13:59:09.847 回答
0

参考https://github.com/pyFFTW/pyFFTW/issues/303

  1. brew install fftw

  2. 安装库LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include -Wno-error=implicit-function-declaration" python setup.py install

于 2021-11-06T10:31:03.373 回答