小编Ant*_*kat的帖子

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

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
Run Code Online (Sandbox Code Playgroud)

此错误特定于 Python3.11版本。在 Python 上,3.10.6 …

python linux pip python-3.x aiohttp

25
推荐指数
4
解决办法
8万
查看次数

如何指定函数参数的类型 (Python)

我想限制可以作为参数传递给另一个函数的函数的范围。例如,将函数限制为仅两个指定的函数之一,或来自特定模块,或通过签名。我尝试了下面的代码,但其中现在有限制:因为参数可以传递任何函数。

这在Python中可能吗?

def func_as_param():
    print("func_as_param called")


def other_func():
    print("other_func called")


def func_with_func_arg(func: func_as_param):  # this is not giving restrictions
# def func_with_func_arg(func: type(func_as_param)):  # this is also not giving restrictions
    print("func_with_func_arg called")
    func()


def test_func_with_func_arg():
    print("test_func_with_func_arg")
    func_with_func_arg(func_as_param)
    func_with_func_arg(other_func)  # <- here IDE must complain that only func_as_param is expected
Run Code Online (Sandbox Code Playgroud)

python generics parameters

4
推荐指数
1
解决办法
8821
查看次数

标签 统计

python ×2

aiohttp ×1

generics ×1

linux ×1

parameters ×1

pip ×1

python-3.x ×1