python AttributeError: module 'pygame' has no attribute 'display'
原问题网址:https://stackoverflow.com/questions/39840580/python-attributeerror-module-pygame-has-no-attribute-display
问题:当一个小哥试图用python中的pygame创建一个窗口时出现了RT问题:
>>> import pygame
>>> (width, height) = (300, 200)
>>> screen = pygame.display.set_mode((width, height))Traceback (most recent call last):File "<pyshell#2>", line 1, in <module>screen = pygame.display.set_mode((width, height))
AttributeError: module 'pygame' has no attribute 'display'
问题原因可能有以下几个方面:
1.需要先使用
pygame.init()
2.确保自己的文件等命名中没有使用pygame.py或者pygame关键字
可以通过以下代码查询是否有此类文件:
import pygameprint('Path to module:',pygame._file_)
3.可能使用的pygame版本没有这个attribute
可以通过dir(pygame)函数来查看当前版本中包含哪些attribute
python AttributeError: module 'pygame' has no attribute 'display'相关推荐
- Python AttributeError: 'module' object has no attribute 'posseg'
AttributeError: 'module' object has no attribute 'posseg' 遇到问题: 如果 a 是个目录, b 是个 b.py 文件, func 是 b.py ...
- Python 报错解决:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
早上升级完pip,后报错如下: -> # pip install --upgrade pwntools /usr/local/lib/python2.7/dist-packages/pip/_v ...
- Python中出现:AttributeError: module 'numpy' has no attribute 'dtype'问题解决
QUESTION:Python中出现:AttributeError: module 'numpy' has no attribute 'dtype'问题解决 ANWSER: 这个问题可是困扰了我一天的 ...
- 第一:Python+Allure运行报错AttributeError: module ‘allure‘ has no attribute ‘severity_level‘
1.很多查询结果都是先卸载pytest-allure-adaptor,然后再安装allure-pytest pip3 uninstall pytest-allure-adaptor 2.pip3 in ...
- python中引入包的时候报错AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding‘解决方法?
python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法? 参考文章: (1)pyth ...
- AttributeError: module 'tensorflow' has no attribute 'python'
在程序中出现以下代码,会报错:AttributeError: module 'tensorflow' has no attribute 'python' import tensorflow as tf ...
- python脚本AttributeError: module 'xxxx' has no attribute 'xxxxx'错误解决办法
最近写脚本发现了这样的一个错误,脚本.环境什么的完全正确,但执行的时候却报错:AttributeError: module 'xxxx' has no attribute 'xxxxx',查阅了一些相 ...
- python efficientdet AttributeError: module ‘gast‘ has no attribute ‘Num‘
今天在用efficientDet跑模型的时候,出现了下面的警告: WARNING:tensorflow:Entity <bound method RegressBoxes.call of < ...
- Python异常:AttributeError: module ‘xxxx‘ has no attribute ‘open‘ 解决办法
前言 小编一直在用 Python 做机器学习,项目折腾了这么久,常用的和不常用的组件都安装了一大堆,按理说不能出现少包的问题. 仔细检查了一下代码,果然发现了一个低级问题,引以为戒.分享出来,也希望新 ...
最新文章
- Linux中的文件寻址,Linux文件寻址算法:逻辑地址到物理地址的转换
- 【青少年编程竞赛交流】03月份微信图文索引
- django框架使用mysql报错,及两种解决方法
- java什么是服务治理平台_Java | Spring Cloud 是如何实现服务治理的
- 数据结构——顺序栈和链式栈的简单实现和解析(C语言版)
- jbpm小项目测试_尝试使用jBPM Console NG(测试版)
- 查询笔记 分组与聚合 0314 1207
- Oracle DBA课程系列笔记(4)
- Python获取Linux或Windows系统的基本信息
- Linux c/c++ IDE(开发环境)
- python中in,not in,比较运算符,格式化输出,编码
- python批量切换图片格式的方法
- STM32F103 驱动DS18B20
- django登录注册html页面,Django实现页面注册登录界面
- 公司局域网如何组建 公司局域网搭建方法
- 输入身份证判断性别python最后一位是英文怎么写_身份证号码最后一位,是表示性别用的吗?...
- CIO谈:基于K2 BPM平台怎么做报销?
- linux php配置
- List(updated 2023.01.29)
- (收藏)让你平步青云的十个谈话技巧
热门文章
- c语言实现同步四位加法计数器,八进制计数器设计方案汇总(四款模拟电路原理实现过程)...
- SQL中limit用法
- Code blocks左边管理栏消失
- html中的样式写在什么位置,css样式放在哪里?
- TPS73201DRBT
- A Singular Value Thresholding Algorithm for Matrix Completion
- Linux——进程间通信(共享内存【mmap实现+系统V】)
- APS排程软件在箱包行业的应用
- 黑马Drools学习笔记(三)——Drools规则属性
- Java线程池核心线程数与最大线程数的区别