In a nutshell
On Ubuntu 11.10, for the pygame library, pydev reports "undefined variables from imports". On Windows 7, everything is fine. On both platforms, the code works properly.
This is the same error as this thread (and a bunch of others). Removing and re-adding my interpreter did not change anything. I also tried to include pygame as a forced built-in lib, but it did not change anything (I checked that pygame was in system PYTHONPATH).
Configs
On both Ubuntu and Windows, I'm using Eclipse Indigo and Python 3.2.
On Ubuntu, I'm using:
- Ubuntu 11.10
- Pygame 1.9.2pre compiled from the pygame Hg repo. When built and installed, the site-packages/pygame folder contains a bunch of .so and .py files.
On Windows7:
- Windows 7 pro with SP1
- Pygame 1.9.2pre from lfd.uci.edu. The MSI created a bunch of .pyd and .py to the site-packages/pygame folder.
I understand that static analysis can't go inside .so files on Ubuntu. I also understand that Python is a dynamic language. Hence pydev has limitations inherent to static analysis. But pydev on Windows 7 manages to link the classes inside .pyd files, which are dynamic libs. Why? And how could I make it work on Ubuntu?
Hints?
import pygame
from pygame.locals import *
With the above code in Ubuntu, I can ctrl-click (or f3) to the pygame package, but not to the pygame.locals. On Windows I can go to both.
import pygame
import pygame.locals
from pygame.locals import *
Now I can go to pygame.locals. I guess that helped pydev to figure out what to "expect", since locals.py actually exists in the site-packages/pygame folder. But I don't want to change all my code just to suit pydev.
Anyway, the line below still raises "undefined variable from import" on Ubuntu, but not on Windows.
except pygame.error:
PS: In case that helps, I have a 64 bit Lenovo T410, and installed everything for 64 bits.