【发布时间】:2017-09-07 11:30:18
【问题描述】:
我正在尝试解决 pycharm 向我显示警告的问题:
Cannot find reference 'x' in 'y'
来自 pygame 的东西。
例子:
Cannot find reference 'circle' in 'draw.py'
在“设置 > 项目解释器 > 解释器路径”中,我有:
...
/usr/local/lib/python3.5/dist-packages/
/usr/local/lib/python3.5/dist-packages/pygame-1.9.2b8-py3.5-linux-x86_64.egg
我在这个位置有 pygame。
我能做些什么来消除这些警告?
编辑:
import pygame
import time
pygame.init()
resolution = (200, 200)
screen = pygame.display.set_mode(resolution)
background = pygame.Surface(screen.get_size())
background.fill((255, 255, 255))
background = background.convert()
pygame.draw.circle(background, (0, 0, 0), (100, 100), 50, 2)
screen.blit(background, (0, 0))
pygame.display.flip()
time.sleep(5)
此代码将在白色背景上显示一个黑色圆圈,并且在由 python3 运行时可以正常工作。
但是我在 pycharm 中收到这些警告:
4: Cannot find reference 'init' in '__init__.py'
6: Cannot find reference 'set_mode' in 'display.py'
10: Cannot find reference 'circle' in 'draw.py'
12: Cannot find reference 'flip' in 'display.py'
【问题讨论】:
-
我的第一个猜测是你的 pygame 版本是针对 Py2.7 的;但我想从你的本地路径来看没问题 - 你能给我们展示一个(小)代码示例吗?如果我们提供的不仅仅是示例,我们可能会为您提供更好的帮助
-
添加到主帖的代码示例和警告列表
标签: python-3.x pygame pycharm