python程序中执行报错:
Traceback (most recent call last):
File "XXXXXXXXXXXXXXXX.py", line 237, in <module>
leftpose_radius002 = pose.radius[1]
IndexError: index 1 is out of bounds for axis 0 with size 1 (更多…)
python程序中执行报错:
Traceback (most recent call last):
File "XXXXXXXXXXXXXXXX.py", line 237, in <module>
leftpose_radius002 = pose.radius[1]
IndexError: index 1 is out of bounds for axis 0 with size 1 (更多…)
准备使用xlsxwriter把数据写入到excel里面,报错:
Traceback (most recent call last):
File "XXXXXXXXXX.py", line 134, in <module>
worksheet.write(startnum+1, 1, head_pose.position)
File "XXXXXXXXXX.py", line 85, in cell_wrapper
return method(self, *args, **kwargs)
File "XXXXXXXXXX.py", line 445, in write
return self._write(row, col, *args)
File "XXXXXXXXXX.py", line 517, in _write
raise TypeError("Unsupported type %s in write()" % type(token))
TypeError: Unsupported type <class 'numpy.ndarray'> in write()
检查后发现问题出在数据结构上,比如原程序中,这种数组形式的数据[ 0.0589693 0.05704604 -0.13406745]是不能直接写入到excel里面的
需要先进行一个数据的提取
提取方法是新建一个变量,然后把数组中每一个值赋值给变量
这样就可以导出了,比如原数据:
head_pose.position = [ 0.0589693 0.05704604 -0.13406745]
要这么操作:
通过print(f'XXXXXXXX{变量、字符串}xxxxx')即可,f表示格式化字符串,格式化以后,花括号里面的变量或者字符串就能够用了
比如:
变量IP和PORT,要输出一句话:
位于0.0.0.0的服务端启动成功,在50000端口等待客户链接
那么可以通过print(f来写:
print(f'位于{IP}的服务端启动成功,在{PORT}端口等待客户链接')
print('位于'+str(IP)+'的服务端启动成功,在'+str(PORT)+'端口等待客户链接')
程序报错退出,错误提示:
M = cv2.getRotationMatrix2D(eyesCenter, angle, scale)
TypeError: Can't parse 'center'. Sequence item with index 0 has a wrong type
查询后发现问题出在这行:
eyesCenter = (leftEyeCenter[0] + rightEyeCenter[0] // 2,leftEyeCenter[1] + rightEyeCenter[1] // 2)
eyesCenter = (leftEyeCenter[0] + rightEyeCenter[0] // 2.0,leftEyeCenter[1] + rightEyeCenter[1] // 2.0)
pip 直接安装dlib库出现required to install pyproject.toml-based projects报错,大红字提示无法安装的问题。解决办法:
1、先安装cmake
执行:pip install cmake
2、用conda装:
执行:conda install -c https://conda.anaconda.org/conda-forge dlib
反正是成功了,可以试试
参考:https://blog.csdn.net/qq_43466323/article/details/120855699