【海龟编辑器--imageio库版本安装错误问题】

import traceback
import os
import sys
import platform

# *********************************************************************
# 本程序主要为了解决imageio库版本安装错误问题
# 本程序安装的版本如下:
#   统一需要先卸载imageio版本,不管有没有安装过。后续安装imageio2.5.0
# *********************************************************************

py_path, py_exe = sys.executable.rsplit(os.sep, 1)  # 获取python可执行环境路径,以及可执行环境名称
os.chdir(py_path)  # 切换到对应的路径下,方便执行命令


def get_osname():
    """获取操作系统名称"""
    plt = platform.platform()
    if "Darwin" in plt:
        return "Mac"
    elif "Windows" in plt:
        return "Windows"
    else:
        pass


def handle(version="0.5.10"):
    """处理不同系统版本问题"""
    py_env = ".{}{}".format(os.sep, py_exe)
    os.system("{} -m pip uninstall imageio -y".format(py_env))
    os.system("{} -m pip uninstall imageio-snapshot -y".format(py_env))
    print("即将为您安装imageio {} 版本!".format(version))
    os.system(
        "{} -m pip install imageio=={} -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn".format(py_env, version))
    os.system(
        "{} -m pip install imageio-snapshot -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn".format(py_env))
    print("------->  imageio {} 版本安装成功!".format(version))
    print("------->  imageio-snapshot 安装成功!")


def main():
    """程序入口"""
    osname = get_osname()
    print("您的电脑系统为:{}".format(osname))
    print("正在卸载您电脑中已经存在的imageio版本,请稍后...")
    if osname == "Mac":
        handle("2.5.0")
    elif osname == "Windows":
        handle("2.5.0")


if __name__ == "__main__":
    try:
        main()
    except Exception as e:
        print("安装过程出现了异常,异常信息如下:")
        traceback.print_exc()

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值