Python关闭transformers和torch警告信息输出!

Python屏蔽transformers和torch警告信息方法
该文章已生成可运行项目,

安装indextts的时候,配置成功了,已经可以运行。但是会输出一堆警告⚠️信息!

E:\DEV\Miniconda3\envs\index-tts\lib\site-packages\transformers\utils\generic.py:441: 
FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. 
Please use `torch.utils._pytree.register_pytree_node` instead.
    _torch_pytree._register_pytree_node(

E:\DEV\Miniconda3\envs\index-tts\lib\site-packages\transformers\utils\generic.py:309: 
FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. 
Please use `torch.utils._pytree.register_pytree_node` instead.
    _torch_pytree._register_pytree_node(

E:\DEV\Miniconda3\envs\index-tts\lib\site-packages\transformers\utils\generic.py:309: 
FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. 
Please use `torch.utils._pytree.register_pytree_node` instead.
    _torch_pytree._register_pytree_node(

>> vqvae weights restored from: checkpoints\dvae.pth

E:\DEV\Miniconda3\envs\index-tts\lib\site-packages\transformers\configuration_utils.py:387: 
UserWarning: Passing `gradient_checkpointing` to a config initialization is deprecated and will be removed in v5 Transformers. 
Using `model.gradient_checkpointing_enable()` instead, or if you are using the `Trainer` API, pass `gradient_checkpointing=True` in your `TrainingArguments`.
    warnings.warn(

>> GPT weights restored from: checkpoints\gpt.pth

E:\DEV\Miniconda3\envs\index-tts\lib\site-packages\torch\nn\utils\weight_norm.py:143: 
FutureWarning: `torch.nn.utils.weight_norm` is deprecated in favor of `torch.nn.utils.parametrizations.weight_norm`.
    WeightNorm.apply(module, name, dim)

这东西不影响使用,但是看着十分难受。所以想要屏蔽这些内容。但是有不知道从何处入手。后来发现可以统一管理,挺好。分析一下设置方式。

方法 1:使用 warnings 模块全局禁用警告

在代码开头添加以下内容,可以完全屏蔽所有警告:

import warnings
warnings.filterwarnings("ignore")
  • 优点:简单,适用于快速测试。
  • 缺点:会屏蔽所有警告,包括可能有用的信息。如果只想屏蔽特定警告,不推荐此方法。

方法 2:针对特定警告类型屏蔽

如果你只想关闭 FutureWarningUserWarning,可以指定类别。例如:

import warnings

# 屏蔽 FutureWarning
warnings.filterwarnings("ignore", category=FutureWarning)

# 屏蔽 UserWarning
warnings.filterwarnings("ignore", category=UserWarning)
  • 适用场景:你的输出中主要是 FutureWarningUserWarning,可以用这个方法精确控制。
  • 代码位置:放在脚本开头,导入库之前。

方法 3:针对特定模块或消息屏蔽

如果你只想屏蔽来自 transformerstorch 的特定警告,可以用正则表达式匹配消息内容。例如:

import warnings

# 屏蔽 transformers 中关于 torch.utils._pytree 的警告
warnings.filterwarnings("ignore", message=".*torch.utils._pytree._register_pytree_node.*", category=FutureWarning)

# 屏蔽 weight_norm 的警告
warnings.filterwarnings("ignore", message=".*torch.nn.utils.weight_norm.*", category=FutureWarning)

# 屏蔽 gradient_checkpointing 的警告
warnings.filterwarnings("ignore", message=".*Passing `gradient_checkpointing` to a config initialization.*", category=UserWarning)
  • 优点:更精确,只屏蔽你不关心的警告,保留其他有用的提示。
  • 缺点:需要为每种警告写一行,稍微麻烦。

方法 4:通过命令行运行时禁用

如果你是通过命令行运行 Python 脚本,可以用 -W 参数:

python -W ignore your_script.py
  • 适用场景:临时运行,不想改代码。
  • 注意:这也会屏蔽所有警告。

推荐方案

根据你的输出,我建议用以下代码,既简单又能针对性解决问题:

import warnings

# 屏蔽常见的 transformers 和 torch 警告
warnings.filterwarnings("ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category=UserWarning)

# 你的代码
from transformers import SomeModel
# ... 其他导入和逻辑 ...

把这几行放在脚本最开头,运行时就不会看到这些警告了。

注意事项

  • 检查警告的重要性:这些警告提示某些功能在未来版本会移除。如果你在开发长期项目,建议查看文档,逐步更新代码到推荐的用法,避免未来兼容性问题。
  • 调试时保留警告:如果你在调试代码,建议暂时不要屏蔽警告,它们可能提供有用的线索。

本文章已经生成可运行项目
PS C:\Users\Administrator\Desktop> # 查看 E:\AI_System 目录的结构 PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System -Recurse -Depth 2 | Where-Object {$_.PSIsContainer} | Select-Object FullName FullName -------- E:\AI_System\agent E:\AI_System\AI_Core_Functional E:\AI_System\cache E:\AI_System\cognitive_arch E:\AI_System\config E:\AI_System\core E:\AI_System\data E:\AI_System\environment E:\AI_System\logs E:\AI_System\models E:\AI_System\model_cache E:\AI_System\model_manager E:\AI_System\model_server E:\AI_System\scripts E:\AI_System\security E:\AI_System\temp E:\AI_System\utils E:\AI_System\venv E:\AI_System\web_ui E:\AI_System\agent\affective_modules E:\AI_System\agent\cognitive_system E:\AI_System\agent\conscious_system E:\AI_System\agent\decision_system E:\AI_System\agent\generated_images E:\AI_System\agent\knowledge_system E:\AI_System\agent\models E:\AI_System\agent\tests E:\AI_System\agent\text_results E:\AI_System\agent\utils E:\AI_System\agent\__pycache__ E:\AI_System\agent\affective_modules\__pycache__ E:\AI_System\agent\conscious_system\cognitive E:\AI_System\agent\conscious_system\layers E:\AI_System\agent\conscious_system\logs E:\AI_System\agent\conscious_system\memory E:\AI_System\agent\conscious_system\perception E:\AI_System\agent\conscious_system\states E:\AI_System\agent\conscious_system\__pycache__ E:\AI_System\agent\decision_system\__pycache__ E:\AI_System\agent\models\__pycache__ E:\AI_System\agent\utils\__pycache__ E:\AI_System\cognitive_arch\__pycache__ E:\AI_System\config\__pycache__ E:\AI_System\core\__pycache__ E:\AI_System\data\environment E:\AI_System\environment\__pycache__ E:\AI_System\models\cache E:\AI_System\model_manager\__pycache__ E:\AI_System\model_server\agent_system E:\AI_System\model_server\config E:\AI_System\model_server\core E:\AI_System\model_server\generated_images E:\AI_System\model_server\models E:\AI_System\model_server\resources E:\AI_System\model_server\services E:\AI_System\model_server\ui_components E:\AI_System\model_server\utils E:\AI_System\model_server\__pycache__ E:\AI_System\model_server\agent_system\core E:\AI_System\model_server\agent_system\interaction E:\AI_System\model_server\agent_system\__pycache__ E:\AI_System\model_server\core\__pycache__ E:\AI_System\model_server\resources\icons E:\AI_System\model_server\resources\styles E:\AI_System\security\__pycache__ E:\AI_System\utils\__pycache__ E:\AI_System\venv\Include E:\AI_System\venv\Lib E:\AI_System\venv\Scripts E:\AI_System\venv\share E:\AI_System\venv\Lib\site-packages E:\AI_System\venv\share\man E:\AI_System\web_ui\# E:\AI_System\web_ui\flagged E:\AI_System\web_ui\static E:\AI_System\web_ui\templates E:\AI_System\web_ui\venv E:\AI_System\web_ui\__pycache__ E:\AI_System\web_ui\#\Include E:\AI_System\web_ui\#\Lib E:\AI_System\web_ui\#\Scripts E:\AI_System\web_ui\static\css E:\AI_System\web_ui\static\images E:\AI_System\web_ui\static\js E:\AI_System\web_ui\venv\Include E:\AI_System\web_ui\venv\Lib E:\AI_System\web_ui\venv\Scripts E:\AI_System\web_ui\venv\share PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 特别检查是否有 core 目录 PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\core -ErrorAction SilentlyContinue 目录: E:\AI_System\core Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2025/8/17 10:32 __pycache__ -a---- 2025/8/17 0:05 6643 circuit_breaker.py -a---- 2025/8/17 10:31 2711 config.py -a---- 2025/8/17 0:05 3002 config_loader.py -a---- 2025/8/17 0:05 1214 decision_engine.py -a---- 2025/8/17 0:05 563 dependency_manager.py -a---- 2025/8/17 0:05 8464 environment.py -a---- 2025/8/17 0:05 195 environment_interface.py -a---- 2025/8/17 0:05 16338 exceptions.py -a---- 2025/8/17 0:05 3 genetic_code.py -a---- 2025/8/17 0:05 1375 metrics.py -a---- 2025/8/17 0:05 578 models.py -a---- 2025/8/17 23:58 1683 module_loader.py -a---- 2025/8/17 0:05 1380 relationship_manager.py -a---- 2025/8/17 0:05 10957 subsystem_registry.py -a---- 2025/8/17 0:05 1945 system_components.py -a---- 2025/8/17 2:20 5770 __init__.py PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 检查是否有 model_loader.py 文件 PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\core\model_loader.py -ErrorAction SilentlyContinue PS C:\Users\Administrator\Desktop> # 安装可能需要的额外依赖 PS C:\Users\Administrator\Desktop> python -m pip install modelscope # 根据警告信息,可能需要这个 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Requirement already satisfied: modelscope in e:\python310\lib\site-packages (1.29.0) Requirement already satisfied: filelock in e:\python310\lib\site-packages (from modelscope) (3.18.0) Requirement already satisfied: requests>=2.25 in e:\python310\lib\site-packages (from modelscope) (2.32.4) Requirement already satisfied: setuptools in e:\python310\lib\site-packages (from modelscope) (80.9.0) Requirement already satisfied: tqdm>=4.64.0 in e:\python310\lib\site-packages (from modelscope) (4.67.1) Requirement already satisfied: urllib3>=1.26 in e:\python310\lib\site-packages (from modelscope) (2.5.0) Requirement already satisfied: charset_normalizer<4,>=2 in e:\python310\lib\site-packages (from requests>=2.25->modelscope) (3.4.2) Requirement already satisfied: idna<4,>=2.5 in e:\python310\lib\site-packages (from requests>=2.25->modelscope) (3.10) Requirement already satisfied: certifi>=2017.4.17 in e:\python310\lib\site-packages (from requests>=2.25->modelscope) (2025.8.3) Requirement already satisfied: colorama in e:\python310\lib\site-packages (from tqdm>=4.64.0->modelscope) (0.4.6) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> python -m pip install transformers[torch] # 确保 transformerstorch 兼容 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Requirement already satisfied: transformers[torch] in e:\python310\lib\site-packages (4.31.0) Requirement already satisfied: filelock in e:\python310\lib\site-packages (from transformers[torch]) (3.18.0) Requirement already satisfied: huggingface-hub<1.0,>=0.14.1 in e:\python310\lib\site-packages (from transformers[torch]) (0.34.3) Requirement already satisfied: numpy>=1.17 in e:\python310\lib\site-packages (from transformers[torch]) (1.26.4) Requirement already satisfied: packaging>=20.0 in e:\python310\lib\site-packages (from transformers[torch]) (25.0) Requirement already satisfied: pyyaml>=5.1 in e:\python310\lib\site-packages (from transformers[torch]) (6.0.2) Requirement already satisfied: regex!=2019.12.17 in e:\python310\lib\site-packages (from transformers[torch]) (2025.7.34) Requirement already satisfied: requests in e:\python310\lib\site-packages (from transformers[torch]) (2.32.4) Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in e:\python310\lib\site-packages (from transformers[torch]) (0.13.3) Requirement already satisfied: safetensors>=0.3.1 in e:\python310\lib\site-packages (from transformers[torch]) (0.5.3) Requirement already satisfied: tqdm>=4.27 in e:\python310\lib\site-packages (from transformers[torch]) (4.67.1) Requirement already satisfied: torch!=1.12.0,>=1.9 in e:\python310\lib\site-packages (from transformers[torch]) (2.0.1) Requirement already satisfied: accelerate>=0.20.3 in e:\python310\lib\site-packages (from transformers[torch]) (0.21.0) Requirement already satisfied: fsspec>=2023.5.0 in e:\python310\lib\site-packages (from huggingface-hub<1.0,>=0.14.1->transformers[torch]) (2025.7.0) Requirement already satisfied: typing-extensions>=3.7.4.3 in e:\python310\lib\site-packages (from huggingface-hub<1.0,>=0.14.1->transformers[torch]) (4.14.1) Requirement already satisfied: psutil in e:\python310\lib\site-packages (from accelerate>=0.20.3->transformers[torch]) (7.0.0) Requirement already satisfied: sympy in e:\python310\lib\site-packages (from torch!=1.12.0,>=1.9->transformers[torch]) (1.13.3) Requirement already satisfied: networkx in e:\python310\lib\site-packages (from torch!=1.12.0,>=1.9->transformers[torch]) (3.4.2) Requirement already satisfied: jinja2 in e:\python310\lib\site-packages (from torch!=1.12.0,>=1.9->transformers[torch]) (3.1.6) Requirement already satisfied: colorama in e:\python310\lib\site-packages (from tqdm>=4.27->transformers[torch]) (0.4.6) Requirement already satisfied: MarkupSafe>=2.0 in e:\python310\lib\site-packages (from jinja2->torch!=1.12.0,>=1.9->transformers[torch]) (2.1.5) Requirement already satisfied: charset_normalizer<4,>=2 in e:\python310\lib\site-packages (from requests->transformers[torch]) (3.4.2) Requirement already satisfied: idna<4,>=2.5 in e:\python310\lib\site-packages (from requests->transformers[torch]) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in e:\python310\lib\site-packages (from requests->transformers[torch]) (2.5.0) Requirement already satisfied: certifi>=2017.4.17 in e:\python310\lib\site-packages (from requests->transformers[torch]) (2025.8.3) Requirement already satisfied: mpmath<1.4,>=1.1.0 in e:\python310\lib\site-packages (from sympy->torch!=1.12.0,>=1.9->transformers[torch]) (1.3.0) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> python -m pip install accelerate # 用于模型加速 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Requirement already satisfied: accelerate in e:\python310\lib\site-packages (0.21.0) Requirement already satisfied: numpy>=1.17 in e:\python310\lib\site-packages (from accelerate) (1.26.4) Requirement already satisfied: packaging>=20.0 in e:\python310\lib\site-packages (from accelerate) (25.0) Requirement already satisfied: psutil in e:\python310\lib\site-packages (from accelerate) (7.0.0) Requirement already satisfied: pyyaml in e:\python310\lib\site-packages (from accelerate) (6.0.2) Requirement already satisfied: torch>=1.10.0 in e:\python310\lib\site-packages (from accelerate) (2.0.1) Requirement already satisfied: filelock in e:\python310\lib\site-packages (from torch>=1.10.0->accelerate) (3.18.0) Requirement already satisfied: typing-extensions in e:\python310\lib\site-packages (from torch>=1.10.0->accelerate) (4.14.1) Requirement already satisfied: sympy in e:\python310\lib\site-packages (from torch>=1.10.0->accelerate) (1.13.3) Requirement already satisfied: networkx in e:\python310\lib\site-packages (from torch>=1.10.0->accelerate) (3.4.2) Requirement already satisfied: jinja2 in e:\python310\lib\site-packages (from torch>=1.10.0->accelerate) (3.1.6) Requirement already satisfied: MarkupSafe>=2.0 in e:\python310\lib\site-packages (from jinja2->torch>=1.10.0->accelerate) (2.1.5) Requirement already satisfied: mpmath<1.4,>=1.1.0 in e:\python310\lib\site-packages (from sympy->torch>=1.10.0->accelerate) (1.3.0) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> python -m pip install sentencepiece # 用于文本处理 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Requirement already satisfied: sentencepiece in e:\python310\lib\site-packages (0.2.0) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> python -m pip install protobuf # 协议缓冲区支持 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Requirement already satisfied: protobuf in e:\python310\lib\site-packages (6.31.1) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> # 查看项目是否有配置文件 PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\*.json -ErrorAction SilentlyContinue PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\*.yaml -ErrorAction SilentlyContinue PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\*.env -ErrorAction SilentlyContinue 目录: E:\AI_System Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2025/8/11 23:18 971 .env -a---- 2025/8/8 18:10 158 EAI_System.env PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 查看项目是否有 README 或说明文档 PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\README* -ErrorAction SilentlyContinue PS C:\Users\Administrator\Desktop> Get-ChildItem E:\AI_System\*.md -ErrorAction SilentlyContinue PS C:\Users\Administrator\Desktop> # 修复损坏的包安装 PS C:\Users\Administrator\Desktop> python -m pip install --upgrade pip WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Requirement already satisfied: pip in e:\python310\lib\site-packages (25.2) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> python -m pip check WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) opencv-python 4.12.0.88 has requirement numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 1.26.4. torchaudio 2.8.0+cpu has requirement torch==2.8.0, but you have torch 2.0.1. torchvision 0.23.0+cpu has requirement torch==2.8.0, but you have torch 2.0.1. PS C:\Users\Administrator\Desktop> python -m pip install --force-reinstall modelscope WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Collecting modelscope Downloading modelscope-1.29.0-py3-none-any.whl.metadata (40 kB) Collecting filelock (from modelscope) Downloading filelock-3.19.1-py3-none-any.whl.metadata (2.1 kB) Collecting requests>=2.25 (from modelscope) Downloading requests-2.32.5-py3-none-any.whl.metadata (4.9 kB) Collecting setuptools (from modelscope) Downloading setuptools-80.9.0-py3-none-any.whl.metadata (6.6 kB) Collecting tqdm>=4.64.0 (from modelscope) Downloading tqdm-4.67.1-py3-none-any.whl.metadata (57 kB) Collecting urllib3>=1.26 (from modelscope) Downloading urllib3-2.5.0-py3-none-any.whl.metadata (6.5 kB) Collecting charset_normalizer<4,>=2 (from requests>=2.25->modelscope) Downloading charset_normalizer-3.4.3-cp310-cp310-win_amd64.whl.metadata (37 kB) Collecting idna<4,>=2.5 (from requests>=2.25->modelscope) Downloading idna-3.10-py3-none-any.whl.metadata (10 kB) Collecting certifi>=2017.4.17 (from requests>=2.25->modelscope) Downloading certifi-2025.8.3-py3-none-any.whl.metadata (2.4 kB) Collecting colorama (from tqdm>=4.64.0->modelscope) Downloading colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB) Downloading modelscope-1.29.0-py3-none-any.whl (5.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.9/5.9 MB 83.5 kB/s 0:00:59 Downloading requests-2.32.5-py3-none-any.whl (64 kB) Downloading charset_normalizer-3.4.3-cp310-cp310-win_amd64.whl (107 kB) Downloading idna-3.10-py3-none-any.whl (70 kB) Downloading urllib3-2.5.0-py3-none-any.whl (129 kB) Downloading certifi-2025.8.3-py3-none-any.whl (161 kB) Downloading tqdm-4.67.1-py3-none-any.whl (78 kB) Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB) Downloading filelock-3.19.1-py3-none-any.whl (15 kB) Downloading setuptools-80.9.0-py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 127.6 kB/s 0:00:08 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Installing collected packages: urllib3, setuptools, idna, filelock, colorama, charset_normalizer, certifi, tqdm, requests, modelscope Attempting uninstall: urllib3 Found existing installation: urllib3 2.5.0 Uninstalling urllib3-2.5.0: Successfully uninstalled urllib3-2.5.0 Attempting uninstall: setuptools Found existing installation: setuptools 80.9.0 Uninstalling setuptools-80.9.0: Successfully uninstalled setuptools-80.9.0 Attempting uninstall: idna Found existing installation: idna 3.10 Uninstalling idna-3.10: Successfully uninstalled idna-3.10 Attempting uninstall: filelock Found existing installation: filelock 3.18.0 Uninstalling filelock-3.18.0: Successfully uninstalled filelock-3.18.0 Attempting uninstall: colorama Found existing installation: colorama 0.4.6 Uninstalling colorama-0.4.6: Successfully uninstalled colorama-0.4.6 Attempting uninstall: charset_normalizer Found existing installation: charset-normalizer 3.4.2 Uninstalling charset-normalizer-3.4.2: Successfully uninstalled charset-normalizer-3.4.2 ━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━ 4/10 [colorama] WARNING: The script normalizer.exe is installed in 'E:\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Attempting uninstall: certifi Found existing installation: certifi 2025.8.3 Uninstalling certifi-2025.8.3: Successfully uninstalled certifi-2025.8.3 Attempting uninstall: tqdm Found existing installation: tqdm 4.67.1 Uninstalling tqdm-4.67.1: Successfully uninstalled tqdm-4.67.1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━ 7/10 [tqdm] WARNING: The script tqdm.exe is installed in 'E:\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Attempting uninstall: requests Found existing installation: requests 2.32.4 Uninstalling requests-2.32.4: Successfully uninstalled requests-2.32.4 Attempting uninstall: modelscope Found existing installation: modelscope 1.29.0 Uninstalling modelscope-1.29.0: Successfully uninstalled modelscope-1.29.0 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━ 9/10 [modelscope] WARNING: The script modelscope.exe is installed in 'E:\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. torchaudio 2.8.0+cpu requires torch==2.8.0, but you have torch 2.0.1 which is incompatible. torchvision 0.23.0+cpu requires torch==2.8.0, but you have torch 2.0.1 which is incompatible. Successfully installed certifi-2025.8.3 charset_normalizer-3.4.3 colorama-0.4.6 filelock-3.18.0 idna-3.10 modelscope-1.29.0 requests-2.32.5 setuptools-80.9.0 tqdm-4.67.1 urllib3-2.5.0 PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 或者尝试清理并重新安装所有依赖 PS C:\Users\Administrator\Desktop> python -m pip freeze > requirements.txt WARNING: No metadata found in e:\python310\lib\site-packages WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) PS C:\Users\Administrator\Desktop> python -m pip uninstall -r requirements.txt -y Found existing installation: absl-py 2.3.1 Uninstalling absl-py-2.3.1: Successfully uninstalled absl-py-2.3.1 Found existing installation: accelerate 0.21.0 Uninstalling accelerate-0.21.0: Successfully uninstalled accelerate-0.21.0 Found existing installation: addict 2.4.0 Uninstalling addict-2.4.0: Successfully uninstalled addict-2.4.0 Found existing installation: aiofiles 23.2.1 Uninstalling aiofiles-23.2.1: Successfully uninstalled aiofiles-23.2.1 Found existing installation: altair 5.5.0 Uninstalling altair-5.5.0: Successfully uninstalled altair-5.5.0 Found existing installation: annotated-types 0.7.0 Uninstalling annotated-types-0.7.0: Successfully uninstalled annotated-types-0.7.0 Found existing installation: anyio 4.9.0 Uninstalling anyio-4.9.0: Successfully uninstalled anyio-4.9.0 Found existing installation: attrs 25.3.0 Uninstalling attrs-25.3.0: Successfully uninstalled attrs-25.3.0 Found existing installation: basicsr 1.4.2 Uninstalling basicsr-1.4.2: Successfully uninstalled basicsr-1.4.2 Found existing installation: bidict 0.23.1 Uninstalling bidict-0.23.1: Successfully uninstalled bidict-0.23.1 Found existing installation: blinker 1.9.0 Uninstalling blinker-1.9.0: Successfully uninstalled blinker-1.9.0 Found existing installation: Brotli 1.1.0 Uninstalling Brotli-1.1.0: Successfully uninstalled Brotli-1.1.0 Found existing installation: certifi 2025.8.3 Uninstalling certifi-2025.8.3: Successfully uninstalled certifi-2025.8.3 Found existing installation: cffi 1.17.1 Uninstalling cffi-1.17.1: Successfully uninstalled cffi-1.17.1 Found existing installation: chardet 4.0.0 Uninstalling chardet-4.0.0: Successfully uninstalled chardet-4.0.0 Found existing installation: charset-normalizer 3.4.3 Uninstalling charset-normalizer-3.4.3: Successfully uninstalled charset-normalizer-3.4.3 Found existing installation: click 8.2.1 Uninstalling click-8.2.1: Successfully uninstalled click-8.2.1 Found existing installation: colorama 0.4.6 Uninstalling colorama-0.4.6: Successfully uninstalled colorama-0.4.6 Found existing installation: contourpy 1.3.2 Uninstalling contourpy-1.3.2: Successfully uninstalled contourpy-1.3.2 Found existing installation: cryptography 41.0.2 Uninstalling cryptography-41.0.2: Successfully uninstalled cryptography-41.0.2 Found existing installation: cycler 0.12.1 Uninstalling cycler-0.12.1: Successfully uninstalled cycler-0.12.1 Found existing installation: Deprecated 1.2.18 Uninstalling Deprecated-1.2.18: Successfully uninstalled Deprecated-1.2.18 Found existing installation: diffusers 0.19.3 Uninstalling diffusers-0.19.3: Successfully uninstalled diffusers-0.19.3 Found existing installation: diskcache 5.6.3 Uninstalling diskcache-5.6.3: Successfully uninstalled diskcache-5.6.3 Found existing installation: dnspython 2.7.0 Uninstalling dnspython-2.7.0: Successfully uninstalled dnspython-2.7.0 Found existing installation: einops 0.8.1 Uninstalling einops-0.8.1: Successfully uninstalled einops-0.8.1 Found existing installation: eventlet 0.40.2 Uninstalling eventlet-0.40.2: Successfully uninstalled eventlet-0.40.2 Found existing installation: exceptiongroup 1.3.0 Uninstalling exceptiongroup-1.3.0: Successfully uninstalled exceptiongroup-1.3.0 Found existing installation: fastapi 0.116.1 Uninstalling fastapi-0.116.1: Successfully uninstalled fastapi-0.116.1 Found existing installation: ffmpy 0.6.1 Uninstalling ffmpy-0.6.1: Successfully uninstalled ffmpy-0.6.1 WARNING: No metadata found in e:\python310\lib\site-packages Found existing installation: filelock 3.18.0 error: uninstall-no-record-file × Cannot uninstall filelock 3.18.0 ╰─> The package's contents are unknown: no RECORD file was found for filelock. hint: You might be able to recover from this via: pip install --force-reinstall --no-deps filelock==3.18.0 PS C:\Users\Administrator\Desktop> python -m pip install -r requirements.txt WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Processing e:\ai_temp\basicsr-1.4.2 (from -r requirements.txt (line 9)) ERROR: basicsr@ file:///E:/ai_temp/BasicSR-1.4.2 from file:///E:/ai_temp/BasicSR-1.4.2 (from -r requirements.txt (line 9)) does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found. PS C:\Users\Administrator\Desktop> # 将项目根目录添加到 Python 路径 PS C:\Users\Administrator\Desktop> $env:PYTHONPATH = "E:\AI_System" PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 然后尝试运行服务器 PS C:\Users\Administrator\Desktop> python server.py E:\Python310\python.exe: can't open file 'C:\\Users\\Administrator\\Desktop\\server.py': [Errno 2] No such file or directory PS C:\Users\Administrator\Desktop> # 创建虚拟环境 PS C:\Users\Administrator\Desktop> python -m venv venv PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 激活虚拟环境 PS C:\Users\Administrator\Desktop> .\venv\Scripts\activate.ps1 (venv) PS C:\Users\Administrator\Desktop> (venv) PS C:\Users\Administrator\Desktop> # 在虚拟环境中安装依赖 (venv) PS C:\Users\Administrator\Desktop> pip install flask transformers torch numpy pandas scikit-learn Collecting flask Downloading flask-3.1.2-py3-none-any.whl (103 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.3/103.3 kB 10.2 kB/s eta 0:00:00 Collecting transformers Downloading transformers-4.55.3-py3-none-any.whl (11.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.3/11.3 MB 12.0 kB/s eta 0:00:00 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/torch/ Collecting torch Downloading torch-2.8.0-cp310-cp310-win_amd64.whl (241.4 MB) ━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34.8/241.4 MB 16.8 kB/s eta 3:25:30
08-22
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值