How can I make Pygame work with Pydev? - eclipse

I'm working off the latest Mac OS trying to set up my programming environment. Right now what I want to do is to get Pygame working with Pydev so I can do my Python programming from Eclipse. What I've done so far is installed Python 2.6 from python.org and then installed pygame 1.9 from the site.
What happens is that when I try running Python from the command line, I am able to import pygame without a hitch, but when I try to do the same thing from Eclipse, it doesn't work.
I think it might be because Pydev doesn't know where to find Python, in which case I would like some help on how to make sure it's pointing to the right one.
Thanks!

I work with Eclipse on Windows, but I believe that the Mac version eclipse should be the same.
In Eclipse,
click Windows > Preferences,
expand PyDev from left side,
find Interpreter - Python,
switch to Libraries tab,
click New Folder on the right hand,
navigate to your pygame path, and
click Apply and OK.
Turn to your Python project in eclipse,
right click on it,
choose PyDev - Interpreter/Grammar,
choose Python as Project type,
choose 3.0 or your correspond Python version from Grammar,
at last make sure the Interpreter you are using is the same as the one you just configured.
Build your project from eclipse, and it should work.

In Eclipse, Window->Preferences, expand Pydev and choose Interpreter - Python. Then specify your python path. Try first by clicking "Auto Config" to auto-locate your python installation. Then click Apply and Ok.
Make sure this much works by creating a new Python project (without worrying about Pygame yet).
I tested these instructions from Eclipse Helios on Windows. Hope it works for you.
http://www.vogella.de/articles/Python/article.html

If autoconfig is not finding 2.6 you can add it manually at Preferences/PyDev/Interpreter - Python. There you have to press New and set the path for your Python executable.
For Python2.6 the path is: /System/Library/Frameworks/Python.framework/Versions/2.6/bin/Python2.6
For Python2.7 (and higher), the path is different:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Those paths work on OS X 10.6.8, might change for other versions.

Do what the people says, and if that does not work, make sure that you have downloaded the development package.

On menu Window > Preferences > PyDev > Interpreters > Python Interpreters
If your python interpreter config have a pygame and don't work, try to put on force bultins the new keyword "pygame"

Python part
Install Python 3.5.2 32 bits (From python.org)
Download the right pyGame library for 3.5.x 32 bits (It will be pygame-1.9.2b1-cp35-cp35m-win32.whl)
Open the system console and go to the folder where the library was download.
Write in the console: pip install pygame-1.9.2b1-cp35-cp35m-win32.whl
This should install the pygame library.
Note: If the pip version is not the last one, upgrade it. (In this step you should know how, just pay attention.)
Eclipse Part
Open Eclipse
Go to Help>Install new software.
Look for the botton "Add" in the right top corner.
In Location put http://pydev.org/updates. Put a cute name, too. Then click OK.
Check pyDev checkbox. Go next, Finish. Accept licenses. In simple words: Install it.
Go to Window>Preferences>pyDev>Interpreters>Phyton interpreter.
In the Python interpreters part, click Quick Auto-Config.
Note: If you want to do this manually, you should know the path where you installed Python and search for python.exe
Some libraries should manifest in the libraries tab. Click apply.
In the libraries tab, click New Folder.
Search for PyGame installation path (In my case, C:\Python\Python35-32\include\pygame but it's always on Python installation path plus include\pygame, ok?)
Click Accept.
Go to Forced Builtins tab. Click New... and add 'pygame'.
Apply again ! (You should know that I do this only for safety. You can apply just one time.
Click OK.
Test
File> New> Proyect...> PyDev> PyDev Proyect.
Click Next
Complete the Proyect Name. On Grammar Version combobox, select 3.0 - 3.5 and in interpreter choose python.
Note: "Quick Auto-Config" named "python" to the interpreter. If you did this part manually, you should know the exact name because you named it.
Try simple code
import pygame
print(pygame.ver) # This should print the pygame version.
pygame.init() # This does nothing by now, just checking code.

I wasted forever trying to get this to work as well..
I eventually found these steps (you don't need them all just part of my struggles shared).
in Python Shell:
import sys
print (sys.path)
Noticed NO PYGAME in path.
Eventually I GAVE UP on the .exe binaries and was told to use .WHL files and Python PIP to install. but was told NOT VALID wheel file. (frustrating).
what EVENTUALLY WORKED was to (in windows, but similar should work in other OS's).
run Command Prompt as Administrator (just to be sure) Maybe same in other OS's. you'd have to try.
from C:> i Changed Dir to my Python.exe (or the python program itself).
from my python directory in command prompt I typed the following (Like I would a Linux apt-get install command):
**
python.exe -m pip install pygame
**
Shortly after, there were hash marks ##### indicating a download was taking place (Linux type progress bar in shell).
in ECLIPSE without ever changing the Libraries folder to include PyGame folders I was able to run a sample Python PYGAME Script sample (I got a white screen but haven't gone further yet). I was just HAPPY to not have to see the trace back error message :)
now I am finished typing this to you I will be going to test it out further.
Just thought this would help someone :0)

I met such problem in Python 3.6 using LiClipse (which should be similar as Eclipse). It's solved by import pygame as
import pygame
from pygame.locals import *
Then add the pygame folder to Window>Preferences>PyDev>Interpreters>PyDev>Libraries, type in 'pygame' in the Forced BuiltIns tab at the same page, also right click the project, change Properties>PyDev-PYTHONPATH>Source from {proj_dir_name}/ to {proj_dir_name}/src
Maybe some above steps are not necessary. Anyway doing all aboves solves the problem in my case.

Related

VS Code importing the multiarray numpy extension module failed

import numpy
is not working. This started because I couldn't get PyQt5 to work on my home computer. In the Spyder IDE, I can import modules and get everything working fine, but in VS Code, I can't import basic modules. I'm on Windows 10 with Python 3.7. I've Googled a lot and have tried these:
Uninstall Anaconda and VS Code, and reinstall both
In VS Code, press Ctrl+Shift+P, Select Interpreter, and select Python 3.7.1 64-bit ('base':conda), ~\Anaconda3\python.exe
I saw on another similar question that python3.dll may be missing from one of my Anaconda directories, but it is indeed there.
Add environment variable to PATH by going to System Properties > Advanced tab > Environment Variables... > under System Path, Edit, New > C:\Users\myname\Anaconda3\Scripts
Once I did #4 above, the new error message in VS Code when importing numpy is DLL load failed: The specified module could not be found. And in the terminal, I see: The term 'conda' is not recognized as the name of the cmdlet, ...
One thing I notice is in a Python prompt (not Anaconda) I type:
import sys
print(sys.version)
The output is 3.7.2, while in VS Code, the Select Interpreter (see above #2) says Python 3.7.1. Not sure if this is important.
Any help? Everything works on my work computer fine, but it's just my home computer that is being difficult.
What ended up working for me is downgrading my Python installation from 3.7.1 to 3.6.4 with:
conda install python=3.6.4
Hope this helps someone out there.
On another question for the same problem, there was a suggestion that worked for me.
Put this on the variable path.
C:\Users\<Your user name>\Anaconda3\Library\bin
credit to user1024.

Unable to run .robot files in Eclipse Oxygen in Mac

I have a Mac laptop and have installed RED in Eclipse Oxygen version. When I try to run a .robot file in Eclipse I see the popup RunTime Environment Error with the message "Unable to provide valid RED environment. Check python/ robot installation and set it in Preferences". I do not see this issue in Windows machine.
This errors tells that RED could not found Python+Robot installation using command which/whereis. This can be verified by going to Windows->Preferences->RobotFramework -> Installed Frameworks. That part should show you list of python interpreters with robot - in your case either could be empty (no python found) or entry with red color (python without robot found).
On Windows usually Python is added to PATH so it is visible and discovered by RED, somehow Mac does not do this by default (you are not the first person with such issue).
Go to Windows->Preferences->RobotFramework -> Installed Frameworks, there is Add.. button and provide path where python executable is located. I do not have MacOS to provide you usual path, under linux (Centos,Ubuntu) it is in /usr/bin . Take note that RED looks for python filename, if your installation renamed it to python3,python2,py2,py3 or other just make a copy to python.
I will make an Help topic about finding python installations when python is not in PATH as it seems it is more common than I fought.
If you have any other questions, it is better to create GitHub issue: https://github.com/nokia/RED/issues

How do I use Eclipse for Scheme development?

Has anyone succeeded in running and debugging Scheme with Eclipse?
I've tied several plug-ins (scheme 48, schemeway) and couldn't get them working. I'm not sure why they won't work; I downloaded an interpreter (kawa, mit-scheme) and tried to configure it in the plugin but nothing happened (except that mit-scheme threw some errors).
I know there is another way - Racket, but I prefer not to use another IDE. I work with many languages and I'd like to be able to use one IDE for all of them.
Any suggestions?
EDIT:
I tried to run the simplest .scm file (that has only (+ 1 1) in it). By configuration of the plug-ins I mean that I choose an external interpreter and then choose the kawa/mit-scheme interpreter exe file. When I choose kawa with schemeway it open a new window and waited for my input (I didn't have any input - JUST wanted to run the file...). When I did it with mit-scheme interpreter I got this error...
I am using linux-centOS 6.
Found the solution - here it is if someone else will encounter the same error:
There are 2 step when trying to work with Scheme 48 in Eclipse:
install the plugin - just follow http://s48.org/sdt/
install the interpreter - I finally found 2 that I can work with :
Scheme 48 (I use ubuntu so I typed scheme48 in the command line and it gave me the package that I need to install (I think it was
sudo apt-get install scheme48)). Then open the preferences in
Eclipse and go to scheme48->interpreter and check that the
command line is scheme48.
guile - I think that it is supported by gnu. It also the one I prefer. It had less errors and more understandable error output in the consul. Again, to install it I just typed guile in the command line and it gave me 3 versions. I installed 1.8. after installation I created a scheme project and a simple file. go to the preferences and changed the command line to "guile" and the working directory to the path of the project I just created. to load the file just search for the load file into interpreter button (or press Ctrl+F6).

use c++11 on mac os x mountain lion with eclipse (Juno or Kepler)

hey everyone I am just starting to use c++11, which I need for uni, a have a mac and I am familiarise with eclipse (I have both Juno or Kepler with CDT), but as much as I tried I can not run properly any c++11 features in eclipse or compile any code, there is someone that has been in my same position and please help me, seriously I already try all the previous threads about, but for my frustration i am still compiling everything on terminal and editing all in gedit with is not the most confortable way, by the way I have to compile with g++-4.7 as command not g++ meaning that still I have the old OS gnu,please someone just explain me step by step what to do I am terribly frustrated, I beg!!!!
ps. just clarify i install gcc 4.7 with homebrew but the path is different than the original (/usr/local/bin instead of the regular /usr/bin which I believe eclipse use and the reason I can't work with it, thank you for all guys)
Well after trying different things and expending tedious time fixing my issue I will answer my own question with the hope someone with my same needs will not experiment such annoying situation.
First as in a lot of forums remark and is well know the gcc compiler provided for the Mac OS is old and obsolete (more than 5 years old is a lot in computing terms), so first step to work with c++11 is to get a new version of the gcc.
There are two options with the packets common managers (homebrew and macports), I have to say that I was that frustrated that i tried both to see if was a problem of the version in the packet manager even thought should be the same, but for my surprise there is a small difference which later I will explain, which bring me to suggest use macport because with macports the eclipse will work as smooth as with the old c++ while with the installation with homebrew the compilation will be the same than the macport but eclipse will complain about the new grammar in the c++11 (eclipse will tell you that the resource couldn't be resolve, even do compile properly ).
The steps for this are assuming you have the command line already:
download the appropriate macports from the official web page(google it)
in terminal type the following commands
sudo port selfupdate
sudo port upgrade outdated
sudo port install -d gcc47
port select --list gcc
with this you have gcc and will show you which are the gcc installed in you mac now just missing select as defauld the new gcc, do it with.
- sudo port select gcc mp-gcc47
3 having install in my case eclipse kepler create a new C++ project, but instead to left everything standar do the next:
- in the wizard window select as toolchain the cross GCC as the toolchain(for example ni the executable Hello World c++ project), put a random name and next , following window press next now here in the window for the selection of the compiler give the path for the new gcc(the default is /opt/local/bin) as prefix leave it empty and press now the finish bottom.
4 Now go to project properties and in c/c++ build select settings and in the tool settings tab go to miscellaneous in cross g++ compiler and in other flags add -std=c++11.
5 by the last go to c/c++ general -> paths and symbols and select the tab symbols and in select the gnu c++ language and press add to type GXX_EXPERIMENTAL_CXX0X as name just that and press ok.
Now just press apply and ok, after that your mac should be running c++11 in eclipse.
Hope works for you as for me see you around guys.
Note probably you will be to configurate the run but it is more simpler than you thing just go to run -> run configurations and double click in c/c++ application now almost everything is generate for you just you have to fill up the first label with the path to the out put of the compiler (I asumme that you already build the project which will generate the executable file ) normally that file is in the debug folder of the project with the same name than the file compiled n does all.
have a good one guys.

Can't run eclipse on netbook MSi wind! HELP

I just got this MSI wind netbook and tried to run eclipse on it. I installed JDK6 on the netbook already. Whenever I open eclipse there is nothing show up on the screen except a "warning sound" that alerts. What is the problem here?
ps.I just started learning java.
Most likely the Eclipse starter program can't find where you installed Java. Since Eclipse is a Java program, it needs a JRE installed (comes with the JDK typically) to run. Assuming you're running Windows on your MSI Wind, check to make sure the java executable is on your path in your computer environment settings (windows key + printscreen button, or windows key + pause button are the shortcuts to open the computer properties dialog if I remember correctly. Then go to advanced).
You can test if java is on the path by opening a cmd.exe shell window and typing 'java'. If it says it cannot find java, then you need to fix the path.
See this link for additional troubleshooting details: http://www.eclipsezone.com/eclipse/forums/t99010.html
You could try reinstalling the JDK. Perhaps having it on a different disk than the default (D: versus C:) is causing some trouble? It certainly isn't a problem with the hardware, I'm running Eclipse on Windows on an MSI Wind.
Use "Add/Remove programs" in the control panel to remove the java versions you have installed.
Then visit "java.com" and use it to install Java, and verify that it is working. You do not need more than that to use Eclipse.