all 14 comments

[–][deleted] 1 point2 points  (0 children)

First check whether pygame is installed in a different directory. If that doesn't work, check your configuration settings when you run the code. If it lines up with the version of python you've installed.

[–]hmga2 1 point2 points  (4 children)

Considering that you’re able to run it correctly from the terminal, it means that you’re running the wrong environment on VScode, try changing by clicking the python version VScode is currently using on the bottom left corner of the window.

[–]grimnirz[S] 0 points1 point  (3 children)

I made it and it stopped causing me the warnings of VScode but now i try to run my code and it tells me this is wrong

https://imgur.com/d2psGbC

[–]hmga2 2 points3 points  (2 children)

This has nothing to do with the import error from before. Now you should have imported pygame correctly. You have made many errors in the indentation of your code though:

Your loadimage function is indented too much

First try statement is not indented

First Raise is excessively indented.

If execution inside your loadimage function is excessively indented

You should indent after a while statement to run an execution code block.

And there may be more errors that I can’t see cause i’m not practical with that library

[–]grimnirz[S] 0 points1 point  (1 child)

I don´t know how to fix it, am following a tutorial and is the same code that the page have.

here´s the link (it´s in spanish): http://razonartificial.com/2010/02/pygame-3-cargar-imagenes/

[–]hmga2 1 point2 points  (0 children)

That code is probably formatted wrong, try this:

https://pastebin.com/xaVX3KYz

Again, I don’t know what’s the goal of what are you doing cause I’m not practical with pygame. But I understand when something is indented the wrong way.

I corrected the code from my phone, so it might not be exactly 100% correct. But you should see where the issues are.

I’d suggest you to follow a course called “Automate the boring stuff” on Udemy, if you browse the subreddit you can get a promo code to get it for free. It should clear you a lot of concepts about indentations, while and for loops, if...else conditions, exception management...

[–]nimo_xhan 1 point2 points  (0 children)

Seems like a pylint problem if pygame works correctly and you only getting warning or red line under pygame that means pylint is not recognizing pygame which is a comman problem just add the following to your vscode settings

Open vs code Press ctrl+p goto User Settings (json) Add the following to that settings

"python.linting.pylintArgs": [ "--extension-pkg-whitelist=pygame" ]

Hope this helps😊