错误:无法为aiohttp构建wheels,这是安装基于pyproject.toml的项目所需的。

17
Python版本:3.11
通过"pip install -r requirements.txt"安装应用程序的依赖项时出现以下错误:
socket.c -o build/temp.linux-armv8l-cpython-311/aiohttp/_websocket.o
aiohttp/_websocket.c:198:12: fatal error: 'longintrepr.h' file not found
#include "longintrepr.h"                                   
          ^~~~~~~                        1 error generated.
error: command '/data/data/com.termux/files/usr/bin/arm-linux-androideabi-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 aiohttp
Failed to build aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install
pyproject.toml-based projects

这个错误只出现在 Python 3.11 版本中。在 Python 3.10.6 版本中安装是正常的。
相关问题:yarl/_quoting.c:196:12: fatal error: 'longintrepr.h' file not found - 1 error generated
7个回答

19

2
我可以使用Python 3.11.6来构建它。但是无法使用3.12构建,所以我认为这只影响到3.12版本。 - undefined
只有影响到 Python 3.12 版本...https://stackoverflow.com/questions/77388920/warning-c4996-py-optimizeflag-deprecated-in-3-12-aiohttp-websocket-c3042 - undefined

17

4
如果你像我一样在将aiohttp版本降级为3.8.1时遇到了一些问题,你可以尝试其他方法。
  • Download the .whl file manually from alpaca_trade_api-2.3.0-py3-none-any.whl

  • Then open the .whl file with 7-zip.

  • Go to alpaca_trade_api-2.3.0.dist-info\METADATA

  • Open this file for edit and change the requirement in line 21

    from:

       Requires-Dist: aiohttp (==3.8.1)
    

    to:

       Requires-Dist: aiohttp (==3.8.4)
    
  • Save this change.

  • Go to terminal and install this wheel manually

     python -pip instal (file_location)/alpaca_trade_api-2.3.0-py3-none-any.whl 
    

对我来说很有效。


4
在你的Windows终端上运行,
pip install aiohttp==3.9.0b0


1

总是尝试通过书面方式解决这类问题,比如回答以下问题:

你正在安装什么?

aiohttp

你需要正确版本的依赖吗?

检查你的Python版本,并搜索与你的Python版本兼容的aiohttp版本。在我的情况下,我有python==3.12.0,它与aiohttp==3.9.0b0兼容。

所以只需输入pip install aiohttp==3.9.0b0。


1

这对我有效

pip install aiohttp==3.8.2 yarl==1.8.1 frozenlist==1.3.1 typing-extensions

pip install github==1.2.7 --no-dependencies

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接