简体   繁体   English

PyDev和pygame:导入错误的未定义变量

[英]PyDev and pygame: Undefined Variable From Import Errors

I am making a game using pygame and PyDev. 我正在使用pygame和PyDev制作游戏。 Whenever I reference any member of the pygame module (ie pygame.init ), PyDev gives an "undefined variable from import" error, even though the code itself is perfectly fine. 每当我引用pygame模块的任何成员(即pygame.init )时,PyDev都会给出一个“未定义的导入变量”错误,即使代码本身非常好。 Members of submodules don't give this error message, and using from pygame.locals import * gives "undefined variable" errors. 子模块的成员不会给出此错误消息,并且使用from pygame.locals import *会给出“未定义的变量”错误。

I have tried adding pygame as a forced builtin, to no avail. 我试过添加pygame作为强制内置,但无济于事。 I tried it again and it worked. 我再次尝试了它并且它有效。 I'm not sure what had happened before. 我不确定之前发生了什么。

Code: 码:

import pygame
pygame.init() <== Error raised here

Have you tried adding pygame to the Forced Builtins ? 你有没有尝试过将pygame添加到Forced Builtins

You can find more information on how to do that and why this may fix your issue at: http://www.pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins 您可以在以下位置找到有关如何解决此问题的更多信息以及解决问题的原因: http//www.pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM