这怎么解决: (venv) F:\CODE\Project\AIStudioProxy\AIstud...
Créé le : 22 mai 2025
Créé le : 22 mai 2025
这怎么解决:
(venv) F:\CODE\Project\AIStudioProxy\AIstudioProxyAPI>pip install -U -r requirements.txt
Ignoring uvloop: markers 'sys_platform != "win32"' don't match your environment
Collecting fastapi==0.104.1 (from -r requirements.txt (line 2))
Downloading fastapi-0.104.1-py3-none-any.whl.metadata (24 kB)
Collecting pydantic==2.4.2 (from -r requirements.txt (line 3))
Downloading pydantic-2.4.2-py3-none-any.whl.metadata (158 kB)
Collecting uvicorn==0.23.2 (from -r requirements.txt (line 6))
Downloading uvicorn-0.23.2-py3-none-any.whl.metadata (6.2 kB)
Collecting python-dotenv==1.0.0 (from -r requirements.txt (line 7))
Downloading python_dotenv-1.0.0-py3-none-any.whl.metadata (21 kB)
Collecting websockets==11.0.3 (from -r requirements.txt (line 8))
Downloading websockets-11.0.3-py3-none-any.whl.metadata (6.6 kB)
Collecting httptools (from -r requirements.txt (line 9))
Downloading httptools-0.6.4-cp313-cp313-win_amd64.whl.metadata (3.7 kB)
Collecting playwright (from -r requirements.txt (line 13))
Downloading playwright-1.52.0-py3-none-win_amd64.whl.metadata (3.5 kB)
Collecting aiohttp~=3.11.18 (from -r requirements.txt (line 17))
Downloading aiohttp-3.11.18-cp313-cp313-win_amd64.whl.metadata (8.0 kB)
Collecting requests==2.31.0 (from -r requirements.txt (line 19))
Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting pyjwt==2.8.0 (from -r requirements.txt (line 20))
Downloading PyJWT-2.8.0-py3-none-any.whl.metadata (4.2 kB)
Collecting camoufox[geoip] (from -r requirements.txt (line 14))
Downloading camoufox-0.4.11-py3-none-any.whl.metadata (3.3 kB)
Collecting anyio<4.0.0,>=3.7.1 (from fastapi==0.104.1->-r requirements.txt (line 2))
Downloading anyio-3.7.1-py3-none-any.whl.metadata (4.7 kB)
Collecting starlette<0.28.0,>=0.27.0 (from fastapi==0.104.1->-r requirements.txt (line 2))
Downloading starlette-0.27.0-py3-none-any.whl.metadata (5.8 kB)
Collecting typing-extensions>=4.8.0 (from fastapi==0.104.1->-r requirements.txt (line 2))
Downloading typing_extensions-4.13.2-py3-none-any.whl.metadata (3.0 kB)
Collecting annotated-types>=0.4.0 (from pydantic==2.4.2->-r requirements.txt (line 3))
Downloading annotated_types-0.7.0-py3-none-any.whl.metadata (15 kB)
Collecting pydantic-core==2.10.1 (from pydantic==2.4.2->-r requirements.txt (line 3))
Downloading pydantic_core-2.10.1.tar.gz (347 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [22 lines of output]
Python reports SOABI: cp313-win_amd64
Computed rustc target triple: x86_64-pc-windows-msvc
Installation directory: C:\Users\WindC0X\AppData\Local\puccinialin\puccinialin\Cache
Rustup already downloaded
Installing rust to C:\Users\WindC0X\AppData\Local\puccinialin\puccinialin\Cache\rustup
warn: It looks like you have an existing rustup settings file at:
warn: C:\Users\WindC0X.rustup\settings.toml
warn: Rustup will install the default toolchain as specified in the settings file,
warn: instead of the one inferred from the default host triple.
info: profile set to 'minimal'
info: default host triple is x86_64-pc-windows-msvc
warn: Updating existing toolchain, profile choice will be ignored
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'
Checking if cargo is installed
textCargo, the Rust package manager, is not installed or is not on PATH. This package requires Rust and Cargo to compile extensions. Install it through the system's package manager or via https://rustup.rs/ Checking for Rust toolchain.... Rust not found, installing into a temporary directory [end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
问题的 “罪魁祸首” 就在这几行日志里:
textPython reports SOABI: cp313‑win_amd64 ... Cargo, the Rust package manager, is not installed or is not on PATH. This package requires Rust and Cargo to compile extensions.
你现在用的是 Python 3.13 (cp313)
‑ 3.13 还在开发阶段,许多第三方库(包括 pydantic‑core)暂时没有为它提供预编译的 wheel。
‑ pip 只好回退到「从源代码编译」,而 pydantic‑core 使用 Rust 编写,需要 Rust 编译链(rustc
+ cargo
)。
你的系统里没有 Rust 工具链,于是编译过程直接失败。
方案 | 适用场景 | 步骤 | 优缺点 |
---|---|---|---|
A. 换成稳定版 Python 3.11 / 3.12(推荐) | 对大多数项目最省事 | 1. 下载官方 Windows 安装包(64 bit)<br>2. 重新建虚拟环境 py -3.11 -m venv venv <br>3. pip install -U -r requirements.txt | ✔ 绝大部分库都有现成 wheel;<br>✘ 需要重装 Python/虚拟环境 |
B. 继续用 3.13,但安装 Rust 工具链 | 确实想测试 3.13 | 1. 装 Rust:<br> • Winget:winget install -e --id Rustlang.Rustup <br> • 或 Chocolatey:choco install rust <br> • 或官网下载 rustup-init.exe <br>2. 打开新终端,确认 rustc --version 和 cargo --version 正常输出。<br>3. 重新激活虚拟环境并执行 pip install -U -r requirements.txt | ✔ 不用换 Python;<br>✘ 编译时间长,对后续其他库也可能继续踩坑(很多项目尚未支持 3.13) |
C. 等待官方 wheel 发布 | 不急着用 | —— | ✔ 最省心;<br>✘ 取决于各个项目的适配进度 |
强烈建议:除非你在尝鲜 Python 3.13 的新特性,否则选 方案 A —— 换回 Python 3.11 或 3.12,能免去之后遇到的各种兼容性问题。
powershell# 1. 安装/切换到 Python 3.11 # 官方 MSI 安装时勾选 "Add python.exe to PATH" # 2. 重新创建虚拟环境 py -3.11 -m venv venv .\venv\Scripts\activate # 3. 更新打包工具 python -m pip install --upgrade pip setuptools wheel # 4. 安装依赖 pip install -U -r requirements.txt
pip install -U -r requirements.txt
。如果后续某些库依旧缺 wheel,需要逐个编译或等它们适配。最简单的办法:把 Python 换回 3.11 或 3.12。
不想换?那就装 Rust + VS Build Tools,接受编译源码的等待与可能的额外报错。祝安装顺利!