The Queue module has been renamed to queue in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3。python2 在明年将不再维护,所以现在建议慢慢换。python3下的队列模块已经改为了queue,此模块不需要安装,属于python自带的
1、from queue import Queue 如果不想在原来程序基础上修改,使用此方式import进行调整即可
2、PyMySQL 是在 Python3.x 版本中用于连接 MySQL 服务器的一个库,Python2中则使用mysqldb。
pip3 install PyMySQL
import pymysql
3、
解决问题
TypeError: type numpy.ndarray doesn’t define round method
解决方法
类型错误:numpy.ndarray 类型数据不能定义__round__ method方法
将round方法改为np.round即可!
4、
TypeError: ‘odict_items’ object does not support indexing 或TypeError: ‘dict_items’
res = model.features._modules.items()[layer_index] py2
修改为 res = list(model.features._modules.items())[layer_index] py3
5、
解决问题:_tkinter.TclError: no display name and no $DISPLAY environment variable
解决方法:在脚本导入任何库之前,运行:
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use(‘Agg’)
其余的 见一个总结的特别好的博客:
https://blog.youkuaiyun.com/u013385925/article/details/79615599