报错列表
- Script file` 'E:\Download\Anaconda3\Scripts\pip-script.py' is not present.`
- ImportError: `Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['E:\\Download\\Anaconda3\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.`
- ImportError: `Matplotlib requires numpy>=1.17; you have 1.16.1`
- ZeroDivisionError: `float division by zero`
- ValueError: `You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat`
- ValueError: `operands could not be broadcast together with shapes (82,) (82,2)`
- TypeError:`Object of type 'int32/int64/ndarray' is not JSON serializable`
- TypeError:` 'bytes' object is not callable`
- ValueError: `unsupported format character ':' (0x3a) at index 1915`
- ValueError: `not all arguments converted during string formatting`
Script file 'E:\Download\Anaconda3\Scripts\pip-script.py' is not present.
报错原因:卸载了pip后如何安装pip【更新pip时发生】
参考链接: https://blog.csdn.net/weixin_46088071/article/details/107656035
没有pip怎么用pip安装pip?
没有pip也能安装pip,如下:
(base) C:\Users\admin>pip install pip
Cannot open E:\Anaconda3\Scripts\pip-script.py
(base) C:\Users\admin>E:
(base) E:>
(base) E:>cd E:\Anaconda3\Scripts
(base) E:\Anaconda3\Scripts>
(base) E:\Anaconda3\Scripts>easy_install pip
ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['E:\\Download\\Anaconda3\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.
报错原因:numpy版本冲突
先卸载numpy: pip uninstall numpy
再卸载numpy,直到卸载到提示信息显示,此时完全已经没有numpy了为止。
在安装所需版本的numpy:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.16.1
ImportError: Matplotlib requires numpy>=1.17; you have 1.16.1
报错原因:numpy版本不对
卸载numpy:pip uninstall numpy
重新安装需要的版本:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.18.2
ZeroDivisionError: float division by zero
报错原因:除数为0
数据处理: data = data.fillna(method=‘ffill’)
ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat
报错原因: merge的第一个参数是字符串类型,转化成int
例如:df1[‘a’] = df1[‘a’].astype(int)
将合并关键字转化格式就行,对整个表转格式会出现第二个报错。
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’
ValueError: operands could not be broadcast together with shapes (82,) (82,2)
报错原因:数据格式不对
函数可调用的数据是(82,1),传入数据是(82,2)
检查数据是否有重合项。
TypeError:Object of type 'int32/int64/ndarray' is not JSON serializable
报错原因:json不认numpy的array
参考链接: https://blog.csdn.net/qq_29592829/article/details/100162574
使用tolist()方法将array转换成list
TypeError: 'bytes' object is not callable
报错原因:函数用法出错
加了括号,报错:
data = request.data()
不加括号,能成功输出:
data = request.data
参考链接: https://blog.csdn.net/weixin_45590215/article/details/103673831
ValueError: unsupported format character ':' (0x3a) at index 1915
报错原因:这里使用的 % 在传给mysql中执行的时候被赋予了别的意思,因此需要转义,再加个 % 就行了。
cursor.execute('''SELECT DISTINCT
mf.companycode,
fi.financialratios35,
inst.cinst8,
mf.mfratio10,
cf.cfst36,
mf.mfratio7,
inst.cinst21,
cf.cfst1,
fi.financialratios1,
cf.cfst20,
cf.cfst30
FROM
( ( ( cbsheet bs
INNER JOIN cinst inst ON bs.companycode = inst.companycode )
INNER JOIN cfst cf ON bs.companycode = cf.companycode )
INNER JOIN mfratio mf ON bs.companycode = mf.companycode )
INNER JOIN financialratios fi ON bs.companycode = fi.companycode
WHERE
(bs.reportdate = to_Date('s% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND ( cf.reportdate = to_Date('s% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND (inst.reportdate = to_Date('s% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND (mf.reportdate = to_Date('s% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND (fi.reportdate = to_Date('s% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
'''%(date,date,date,date,date))
再不加%,能成功输出:
cursor.execute('''SELECT DISTINCT
mf.companycode,
fi.financialratios35,
inst.cinst8,
mf.mfratio10,
cf.cfst36,
mf.mfratio7,
inst.cinst21,
cf.cfst1,
fi.financialratios1,
cf.cfst20,
cf.cfst30
FROM
( ( ( cbsheet bs
INNER JOIN cinst inst ON bs.companycode = inst.companycode )
INNER JOIN cfst cf ON bs.companycode = cf.companycode )
INNER JOIN mfratio mf ON bs.companycode = mf.companycode )
INNER JOIN financialratios fi ON bs.companycode = fi.companycode
WHERE
(bs.reportdate = to_Date('s%% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND ( cf.reportdate = to_Date('s%% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND (inst.reportdate = to_Date('s%% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND (mf.reportdate = to_Date('s%% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
AND (fi.reportdate = to_Date('s%% 00:00:00','yyyy-mm-dd hh24:mi:ss') )
'''%(date,date,date,date,date))
参考链接: https://blog.csdn.net/weixin_39358657/article/details/104420770
ValueError: not all arguments converted during string formatting
报错原因:前后数据格式不一致
参考链接: https://blog.csdn.net/lvsehaiyang1993/article/details/80909984