Mac安装tsflex失败:fastparquet编译wheel出错
解决Mac上安装tsflex时fastparquet编译找不到longintrepr.h的问题
问题核心
执行pip3 install tsflex时,依赖的fastparquet 0.6.3版本源码编译失败,报错fastparquet/speedups.c:209:12: fatal error: 'longintrepr.h' file not found。另外注意到你声明使用Python3.9,但报错日志里显示的是Python3.11的路径,大概率是环境里的pip和Python版本不匹配,这也是诱因之一。
解决方案
1. 先对齐Python版本
确保你用的pip对应Python3.9:
- 执行
pip3 --version查看输出路径,如果显示是Python3.11,后续所有命令改用python3.9 -m pip来指定版本执行。
2. 安装预编译的fastparquet,跳过源码编译
旧版本fastparquet(0.6.3)的源码编译不兼容高版本Python的头文件结构,直接安装预编译wheel:
python3.9 -m pip install fastparquet==0.6.3 --only-binary :all:
安装成功后再执行tsflex的安装:
python3.9 -m pip install tsflex
3. (备选)升级fastparquet版本(需确认tsflex兼容性)
如果tsflex可以兼容更高版本的fastparquet,先装新版本:
python3.9 -m pip install fastparquet>=0.8.0
再尝试安装tsflex:
python3.9 -m pip install tsflex
4. 临时指定Python头文件路径(不推荐,仅应急)
找到Python3.9的头文件目录(比如/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/),编译时手动指定:
CFLAGS="-I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/" python3.9 -m pip install tsflex
完整报错信息
Collecting tsflex Using cached tsflex-0.1.1.9-py3-none-any.whl (50 kB) Collecting dill<0.4.0,>=0.3.3 (from tsflex) Using cached dill-0.3.6-py3-none-any.whl (110 kB) Collecting fastparquet<0.7.0,>=0.6.3 (from tsflex) Using cached fastparquet-0.6.3.tar.gz (318 kB) Preparing metadata (setup.py) ... done Requirement already satisfied: numpy<2.0.0,>=1.19.0 in /opt/homebrew/lib/python3.11/site-packages (from tsflex) (1.24.3) Collecting pandas<2.0.0,>=1.2.3 (from tsflex) Using cached pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl (10.8 MB) Collecting pathos<0.3.0,>=0.2.7 (from tsflex) Using cached pathos-0.2.9-py3-none-any.whl (76 kB) Collecting tqdm<5.0.0,>=4.60.0 (from tsflex) Using cached tqdm-4.65.0-py3-none-any.whl (77 kB) Collecting thrift>=0.11.0 (from fastparquet<0.7.0,>=0.6.3->tsflex) Using cached thrift-0.16.0-cp311-cp311-macosx_13_0_arm64.whl Requirement already satisfied: cramjam>=2.3.0 in /opt/homebrew/lib/python3.11/site-packages (from fastparquet<0.7.0,>=0.6.3->tsflex) (2.6.2) Requirement already satisfied: fsspec in /opt/homebrew/lib/python3.11/site-packages (from fastparquet<0.7.0,>=0.6.3->tsflex) (2023.5.0) Requirement already satisfied: python-dateutil>=2.8.1 in /opt/homebrew/lib/python3.11/site-packages (from pandas<2.0.0,>=1.2.3->tsflex) (2.8.2) Requirement already satisfied: pytz>=2020.1 in /opt/homebrew/lib/python3.11/site-packages (from pandas<2.0.0,>=1.2.3->tsflex) (2023.3) Collecting ppft>=1.7.6.5 (from pathos<0.3.0,>=0.2.7->tsflex) Using cached ppft-1.7.6.6-py3-none-any.whl (52 kB) Collecting pox>=0.3.1 (from pathos<0.3.0,>=0.2.7->tsflex) Using cached pox-0.3.2-py3-none-any.whl (29 kB) Collecting multiprocess>=0.70.13 (from pathos<0.3.0,>=0.2.7->tsflex) Using cached multiprocess-0.70.14-py310-none-any.whl (134 kB) Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.11/site-packages (from python-dateutil>=2.8.1->pandas<2.0.0,>=1.2.3->tsflex) (1.16.0) Building wheels for collected packages: fastparquet Building wheel for fastparquet (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [143 lines of output] /opt/homebrew/lib/python3.11/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. !! ******************************************************************************** Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`. ******************************************************************************** !! dist.fetch_build_eggs(dist.setup_requires) running bdist_wheel running build running build_py creating build creating build/lib.macosx-13-arm64-cpython-311 creating build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/encoding.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/util.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/dataframe.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/compression.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/thrift_structures.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/__init__.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/core.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/converted_types.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/api.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/writer.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/schema.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet running egg_info writing fastparquet.egg-info/PKG-INFO writing dependency_links to fastparquet.egg-info/dependency_links.txt writing requirements to fastparquet.egg-info/requires.txt writing top-level names to fastparquet.egg-info/top_level.txt reading manifest file 'fastparquet.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'fastparquet/test/' no previously-included directories found matching 'fastparquet/benchmarks/' no previously-included directories found matching 'test-data/' no previously-included directories found matching 'docs/' adding license file 'LICENSE' writing manifest file 'fastparquet.egg-info/SOURCES.txt' /opt/homebrew/lib/python3.11/site-packages/setuptools/command/build_py.py:201: _Warning: Package 'fastparquet.parquet_thrift' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'fastparquet.parquet_thrift' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'fastparquet.parquet_thrift' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'fastparquet.parquet_thrift' to be distributed and are already explicitly excluding 'fastparquet.parquet_thrift' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /opt/homebrew/lib/python3.11/site-packages/setuptools/command/build_py.py:201: _Warning: Package 'fastparquet.parquet_thrift.parquet' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'fastparquet.parquet_thrift.parquet' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'fastparquet.parquet_thrift.parquet' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'fastparquet.parquet_thrift.parquet' to be distributed and are already explicitly excluding 'fastparquet.parquet_thrift.parquet' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) copying fastparquet/cencoding.c -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/cencoding.pyx -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/parquet.thrift -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/speedups.c -> build/lib.macosx-13-arm64-cpython-311/fastparquet copying fastparquet/speedups.pyx -> build/lib.macosx-13-arm64-cpython-311/fastparquet creating build/lib.macosx-13-arm64-cpython-311/fastparquet/parquet_thrift copying fastparquet/parquet_thrift/__init__.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet/parquet_thrift creating build/lib.macosx-13-arm64-cpython-311/fastparquet/parquet_thrift/parquet copying fastparquet/parquet_thrift/parquet/__init__.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet/parquet_thrift/parquet copying fastparquet/parquet_thrift/parquet/constants.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet/parquet_thrift/parquet copying fastparquet/parquet_thrift/parquet/ttypes.py -> build/lib.macosx-13-arm64-cpython-311/fastparquet/parquet_thrift/parquet running build_ext building 'fastparquet.speedups' extension creating build/temp.macosx-13-arm64-cpython-311 creating build/temp.macosx-13-arm64-cpython-311/fastparquet clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -I/opt/homebrew/lib/python3.11/site-packages/numpy/core/include -c fastparquet/speedups.c -o build/temp.macosx-13-arm64-cpython-311/fastparquet/speedups.o fastparquet/speedups.c:209:12: fatal error: 'longintrepr.h' file not found #include "longintrepr.h" ^~~~~~~~~~~~~~~ 1 error generated. error: command '/usr/bin/clang' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for fastparquet Running setup.py clean for fastparquet Failed to build fastparquet ERROR: Could not build wheels for fastparquet, which is required to install pyproject.toml-based projects
内容的提问来源于stack exchange,提问作者Sira
相关产品推荐
相关产品推荐

