Sadık
Sadık

Reputation: 4419

setting up eclipse for pygame correctly: "unresolved import"

Eclipse shows me an error for

# -*- coding: UTF-8 -*-
import pygame

But when I run the project, pygame obviously works. I can't use the advantages of eclipse IDE like suggestions or auto completion when the editor doesn't 'see' pygame. I wonder why there is no problem in running. Another thing is that it raises an error when I delete the first line with the coding UTF-8.

I have Ubuntu and my project is set up with python2.7. Interpreter is set correct in preferences. In the libraries /dist-packages/pygame is listed.

Upvotes: 0

Views: 2117

Answers (1)

furas
furas

Reputation: 142661

There is no problem with runnning because python knows where pygame is. Eclipse is not python it may not know where pygame is. I don't use Eclipse but maybe you have to add path to pygame in configuration.

# -*- coding: UTF-8 -*- is required by python when you use something more than ASCII for example your native chars - even in comments.

EDIT:

It seems the same problem: How do you import pygame libraries into Eclipse's pydev?

Search "eclipse pygame" on stackoverflow.com to get more.

Upvotes: 1

Related Questions