You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已安装的cv2、numpy库无法导入,程序功能失效求助

未修改代码但cv2、numpy库突然无法导入,图像自动裁剪程序功能失效

我是一名借助ChatGPT开发程序的从业者,有基础编程基础,此前用ChatGPT开发了多个运行正常的业务程序。近期未修改任何代码,但cv2、numpy库突然完全无法使用。

我的代码片段如下:

import os
import cv2
import numpy as np
import tkinter as tk
from tkinter import filedialog

代码中的cv2和numpy被下划线标注且无语法高亮,脚本运行也存在问题。

cv2错误信息

[{
    "resource": "/c:/Users/samda/Desktop/AutoCrop/AutoCrop.py",
    "owner": "_generated_diagnostic_collection_name_#0",
    "code": {
        "value": "reportMissingImports",
        "target": {
            "$mid": 1,
            "path": "/microsoft/pyright/blob/main/docs/configuration.md",
            "scheme": "https",
            "authority": "github.com",
            "fragment": "reportMissingImports"
        }
    },
    "severity": 4,
    "message": "Import \"cv2\" could not be resolved",
    "source": "Pylance",
    "startLineNumber": 2,
    "startColumn": 8,
    "endLineNumber": 2,
    "endColumn": 11
}]

numpy错误信息

[{
    "resource": "/c:/Users/samda/Desktop/AutoCrop/AutoCrop.py",
    "owner": "_generated_diagnostic_collection_name_#0",
    "code": {
        "value": "reportMissingImports",
        "target": {
            "$mid": 1,
            "path": "/microsoft/pyright/blob/main/docs/configuration.md",
            "scheme": "https",
            "authority": "github.com",
            "fragment": "reportMissingImports"
        }
    },
    "severity": 4,
    "message": "Import \"numpy\" could not be resolved",
    "source": "Pylance",
    "startLineNumber": 3,
    "startColumn": 8,
    "endLineNumber": 3,
    "endColumn": 13
}]

该代码用于扫描图像自动裁剪程序,现在点击按钮后无实际裁剪效果,仅提示代码执行完成。


内容的提问来源于stack exchange,提问作者Sam Davis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 21:48:10