1.使用with open(local_file, ‘wb’) as fb下载文件时无法创建本地新文件,并报错No such file or directory:****,且wb提示“Expected type ‘bool’, got ‘str’ instead”
原因:导入库时使用了from openpyxl import *,openpyxl是默认文件存在的
from openpyxl import *
with open(localpath, 'wb') as fp:
ftp.retrbinary('RETR ' + remotepath, fp.write, bufsize)
ftp.set_debuglevel(0)
就会报错:No such file or directory,且wb会提示Expected type 'bool
将from openpyxl import *修改为from openpyxl import load_workbook,一切正常
from openpyxl import load_workbook
with open(localpath, 'wb') as fp:
ftp.retrbinary('RETR ' + remotepath, fp.write, bufsize)
ftp.set_debuglevel(0)
可以正常下载
2.推理时报错:ImportError: cannot import name ‘OrderedDict’ from ‘typing’ (C:\ProgramData\anaconda3\envs\th37\lib\typing.py)![报错图片](https://img-blog.csdnimg.cn/direct/d6ca5502d73b48ba8ed6499b8533afa9.png)
原因:在python3.7.0中,typing模块中没有OrderedDict,但是在python3.7.4中,typing模块中包含OrderedDict,可以直接通过 from typing import OrderedDict 命令导入,本人时python 3.7所以报错
解决方法:python3.8版本及以下,都可以通过安装typing_extensions来解决问题,说它相当于是对typing的一个补丁文件,里面会增加一些typing里面没有的东西,通过pip 安装typing_extensions:pip3 install typing_extensions ,然后打开报错的文件,不从typing中导入OrderedDict模块,而是从typing_extensions中导入OrderedDict模块
修改为,运行即可解决问题
3.训练时报错:OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized
:原因 调用matplotlib存在两个libiomp5md.dll,一个是在anaconda3路径下“C:\ProgramData\anaconda3\Library\bin”,一个是在虚拟环境路径下,将虚拟环境路径下的libiomp5md.dll改为libiomp5md1.dll即可
参考:https://blog.csdn.net/Victor_X/article/details/110082033