美文网首页Python
解决windows环境下安装python rembg包遇到的错误

解决windows环境下安装python rembg包遇到的错误

作者: 微风玉米 | 来源:发表于2020-11-12 14:13 被阅读0次

    前提

    心血来潮想试一下移除图片背景的功能,最终相中了rembg,因为之前没怎么搞过python,在安装和编译 rembg安装包的过程中遇到一些曲折,特地记录一下解决方式。

    • 系统:Windows 10(版本: 10.0.18363)
    • 先将下载源切换到国内镜像,避免连接超时等错误。运行代码pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

    错误

    • 错误:找不到torchvision 0.8.1版本
      • 报错时机:运行pip install rembg之后
      • 具体信息:No matching distribution found for torchvision==0.8.1
      • 解决方式:
        • 在stackoverflow找到解决方法,地址
        • 开代理安装:pip install torch===1.7.0 torchvision===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html --proxy [proxy server]
        • torch-1.7.0包比较大(1.2G),git-bash在下载到600Mb的时候可能会request timeout。可以用浏览器下载,下载地址:https://download.pytorch.org/whl/cu102/torch-1.7.0-cp38-cp38-win_amd64.whl,下载完成后运行pip install ~path/torch-1.7.0-cp38-cp38-win_amd64.whl
    • 错误:找不到msvc
      • 报错时机:编译rembg之时
      • 具体信息:Attempted to compile AOT function without the compiler used by `numpy.distutils` present. Cannot find suitable msvc.
      • 解决方式:安装c编译器

    安装c编译器

    • 原文地址C compiler installation
    • 步骤1:下载安装器
      1. 打开Visual Studio Download页面https://visualstudio.microsoft.com/zh-hans/downloads/
      2. 滚动页面,在『所有下载』下方点击『Visual Studio 2019 工具』


        Visual Studio 2019 工具
      3. 在『Visual Studio 2019 工具』列表下找到『Visual Studio 2019 生成工具』并点击下载
    • 安装 C++ Build Tools
      1. 安装器下载完成之后,打开它并点击,直到进入下图界面之时勾选『C++ build tools』


        C++ build tools
      2. 点击安装按钮

    相关文章

      网友评论

        本文标题:解决windows环境下安装python rembg包遇到的错误

        本文链接:https://www.haomeiwen.com/subject/zsqpbktx.html