python错误汇总

1.错误信息:AttributeError: module ‘pydot‘ has no attribute ‘find_graphviz‘

1.安装pydot-ng
由于pydot里面已经没有这个find_graphviz()方法了,选择安装pydot-ng

activate  python虚拟环境
pip install pydot-ng

2.安装graphviz
graphviz官网上下载exe并点击安装,勾选添加到全局变量。
在这里插入图片描述

或者记住安装位置选择手动添加到path变量里面。

在这里插入图片描述
测试是否安装成功:win+r进入cmd
![在这里插入图片描述](https://img-blog.csdnimg.cn/b1a6a290fa8a42d8bb1d9f7a92bc164f.png

2.gitbash进入虚拟环境报错

错误信息:UnicodeEncodeError: 'gbk' codec can't encode character '\xc1'
解决办法:打开Git Bash ——>右键选择Options ——>设置Locale=zh_CN Character set=GBK ——>关闭Git Bash重新运行conda activate envName ——>成功
在这里插入图片描述

3.运行报错AssertionError: Torch not compiled with CUDA enabled

报错原因:torch的版本和cuda的版本不匹配
解决办法:

  1. cmd 运行:nvidia -smi查看自己的cuda版本

在这里插入图片描述
2.然后去torch官网中查看老版本CUDA适配的torch版本:

https://pytorch.org/get-started/previous-versions/

3.如果没找到合适版本的,去这个pytorh官网的whl文件里面找

https://download.pytorch.org/whl/

在这里插入图片描述cmd 进入whl的文件目录下运行即可

pip install 文件名.whl

4.cuda11.4下载cuda11.3对应的版本

# CUDA 11.3
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113

4.自建虚拟环境的pip更新出错

报错信息:运行 python -m pip install --upgrade pip 没有更新pip的版本
解决办法:
1.先升级pip的版本:参考博客

cmd运行,升级pip的版本

activate base
python -m pip install 

2.复制pip的新版本文件夹到创建的环境里面去

在这里插入图片描述

在这里插入图片描述

5.pip 安装包报错: ssl证书验证失败

错误信息:Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pandas/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) - skipping
解决办法:参考博客
修改命令如下 :

pip install Pandas -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

–trusted-host 是信任这个地址,可以免去ssl验证

6.安装torch报错

错误信息:unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
解决办法:参考博客
使用pip代替conda安装
将命令:

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch

替换为:

pip install torch==1.10.2+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113 --trusted-host pypi.tuna.tsinghua.edu.cn
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值