installing python and eclipse on your pc · click down pydev > interpreters > python...

12
Installing Python and Eclipse on your PC Your first task for the course: get your computer up and running with Python! Some installation instructions for both MacOS and Windows follow below if you need them. If you’re running Linux, you don’t want instructions J. We will be coding in Python 3 for this course – unless you’re already a Python 2 whiz or feel a strong desire to confuse yourself and your instructors, make sure you’re working with this version (any 3.x.x should be fine – most recent is 3.7.3 as of June). Similarly, the strongly suggested development environment for this course is Eclipse, but if you prefer another IDE or text editor based on your previous experience, that’s your business. Having difficulties installing with these instructions? Rule #1: try troubleshooting yourself first! As you probably know, learning to diagnose problems and track down others’ solutions on Google, StackExchange or other online coding forums is a very valuable learning process. This kind of abstract problem solving is the main job description for many coders/analysts/data scientists! Of course, if you’re still having issues after giving it your very best try, feel free to send an email and we’ll help you get set up!

Upload: others

Post on 23-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

InstallingPythonandEclipseonyourPCYourfirsttaskforthecourse:getyourcomputerupandrunningwithPython!SomeinstallationinstructionsforbothMacOSandWindowsfollowbelowifyouneedthem.Ifyou’rerunningLinux,youdon’twantinstructionsJ.WewillbecodinginPython3forthiscourse–unlessyou’realreadyaPython2whizorfeelastrongdesiretoconfuseyourselfandyourinstructors,makesureyou’reworkingwiththisversion(any3.x.xshouldbefine–mostrecentis3.7.3asofJune).Similarly,thestronglysuggesteddevelopmentenvironmentforthiscourseisEclipse,butifyoupreferanotherIDEortexteditorbasedonyourpreviousexperience,that’syourbusiness.Havingdifficultiesinstallingwiththeseinstructions?Rule#1:trytroubleshootingyourselffirst!Asyouprobablyknow,learningtodiagnoseproblemsandtrackdownothers’solutionsonGoogle,StackExchangeorotheronlinecodingforumsisaveryvaluablelearningprocess.Thiskindofabstractproblemsolvingisthemainjobdescriptionformanycoders/analysts/datascientists!Ofcourse,ifyou’restillhavingissuesaftergivingityourverybesttry,feelfreetosendanemailandwe’llhelpyougetsetup!

Page 2: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

A. PythoninstallationonMacOS:MacOSXhasPythonversion2.7“outofthebox,”butwewillusePython3inthiscourse.Todownloadit,startatthiswebsite:https://www.python.org/downloads/.

1. ClickontheMacOSXdownloadlinkforPython3.7.3.

2. Oncedownloaded,runthepackageInstaller.ClickContinuethroughallscreens,acceptinglicensesagreementsasrequired.Finally,clickInstall.

3. That’sit!Python3shouldbefunctional.Ifyouwanttotestthis:

a. OpenMacOS’sTerminalandissuethecommandpython3--version,asshown

below.IfthereturnisPython3.7.3,yourcomputerrecognizesthenewversion.

b. Nexttypepython3toopenaPython3shell.

c. Whentheshellisopen,typeprint(“HelloWorld!”).Iftheterminal’sreturnis

HelloWorld,you’regoodtogo(andasalwaysyoushouldappreciatethatyourcomputeristalkingtoyou:))

d. ToexitthePythonshellinterminal,typeexit().

Page 3: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

B. InstallingPythononWindows:WindowsdoesnottypicallycomewithPython3included,sowewilldownloadandinstallit.Todownload,tohttps://www.python.org/downloads/release/python-373/.

1. Youshouldknowwhetheryourcomputerisrunning32-or64-bitversionof

Windows.Ifyoudon’tknowthis,youcanfigureoutbyfollowingthedirectionsgivenatthiswebsite.

i. Ifyou’rerunning64-bit,onthePythonwebpage,clickonthelinkto

DownloadWindowsx86-64executableinstaller.

ii. Ifyou’rerunning32-bit,onthePythonwebpage,clickonthelinktoDownloadWindowsx86executableinstaller.

2. Double-clickthedownloaded.exefile.Youshouldbeatascreenthatlookslikethe

onebelow.

i. TakecarefulnoteofthefileaddresslistedbelowthelinktoInstallNow.ThisiswhereyourcomputerwillstorePython3.YouwillneedtoknowthisfileaddresstointegratePythonandEclipse(orotherIDEs).

ii. ChecktheboxnexttoAddPython3.7toPATH,thenclickInstallNow.Ifafollowupcontrolwindowasksyoutoallowchangestothecomputer,clickYes.

iii. WewillinstallPythonwithdefaultsettings,sononeedtochangeanything

elserightnow.

Page 4: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

3. Waitfortheprogramtoinstall.Ifallgoeswell,awindowshouldpopupandtellyouSetupwassuccessful.Pythonwasinstalled.

4. Totestthis,openyourCommandPromptfromyourStartmenu.Typepython3--versionintotheinitialcommandline(>).IftheresultcomesbackPython3.7.3,youhavethemostrecentversion.

5. Next,typepythonintothecommandline.OncePythonisopenedintheprompt,trytypingsomemathematicalexpressionsintothe(>>>)commandline(i.e.somethinglike3*5or5876+23).Ifthecomputer’sresponsecomesbackcorrectly,Pythonisinstalledandreadytogo.Typeexit()intothecommandlinetoclosePython.

Page 5: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

C. InstallingEclipse(similarforMacandWindows)ToobtaintheEclipsedesktopplatform,startatthiswebsite:https://www.eclipse.org/downloads/packages/installerTherearesomeinstructionsforinstallationontheEclipsewebsite,butherearesomemoredetailedhighlights:

1. DownloadtheEclipseInstallerfilethatisappropriateforyouroperatingsystem.

2. Unzipthefile(ifneeded)andstarttheInstalleronceitisavailable.

3. Ifyougetamessagesaying“TouseJavacommand-linetools,youneedtoinstallaJDK”,youcandownloadthemostrecentJavaDevelopmentKit(JDK)atthiswebsite.InstalltheJDK(choosingoneappropriatetoyourOS),thenreturntothisstep.

4. Onceyou’vestartedtheInstaller,youshouldgettoaninitiallistofinstalloptions

thatlookslikethewindowbelow.(NotethatitisalsopossibletobetakendirectlytoawindowthatlooksliketheonebelowforStep5.Ifso,skiptostep5.)

5. Clickonthedrop-downmenuiconinthetop-rightcornerandselect“ADVANCEDMODE”.Youshouldbetakentoanewinstallationproductpackagemenu.Fromthismenu,unlessyouwanttoadddevelopmentpackagesforothercodinglanguages(Java,C/C++,etc.),select“EclipsePlatform”,ashighlightedbelow.

Page 6: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

6. Once“EclipsePlatform”isselected,keepclickingNext>untilyoucanselectFinish.(ThenclickFinish).Youshouldbetakentoaprogressboxthatlooksroughlylikethis:

Page 7: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

7. Acceptlicenseagreementsasneededduringsetup.Iftherearenoinstallationproblems,thesoftwareshouldopenitselfuponsetupcompletion.

8. Youmaygetadialogboxaskingyoutoselectadirectoryforyourworkspace(seeimagebelow).Setthisdirectorysomewherethatyouwillbeabletofindlater–itwillbethedefaultlocationforsavingyourpreferences,projects,codework,etc.

9. Whenthesoftwareopens,youwillbetakentoawelcomescreen.NowweneedtointegratePyDevandEclipse.Todothis,navigatetothetopribbonandclickonHelp>InstallNewSoftware…

10. Anpop-upwindowwillopen(seeimagebelow).Inthetextboxthatsays“Workwith”,typethefollowingURL:http://pydev.org/updates.ThenhitENTER.Afterafewmoments,youshouldseetwosoftwareoptionsavailable.Asshownbelow,selectonlytheboxforPyDev(DONOTSELECTtheoptionalMylynbox).

Page 8: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

11. KeepclickingNext>,andagain,acceptlicenseagreementsasneeded.ThenclickFinish.IfyougetaSecurityWarningbox,selectInstallAnyway.Thisshouldfinishtheinstallation.Asoftwareupdatesboxshouldpopup;clickRestartNow.Thesoftwareshouldnowbeopenandupdated.

12. NowweneedtoresetsomepreferencessothatPyDevisreadyforuse.Todothis,findthePreferencestabinthetopribbon.(ForMacOS,thiswillbefoundinEclipse>Preferences…,asshownbelow.ForWindowsOS,IbelieveyoucanfinditinWindow>Preferences).

13. Oncethewindowopens,drilldowntheleft-hand-sidemenutoselecttheinterpreter.ClickdownPyDev>Interpreters>PythonInterpreters.Inthetoprightcorneroftheresultingwindow,youshouldhaveaBrowseforPython/pypyexebutton(inWindows,thisbuttonmightjustbecalledNew…).Clickonit.

Page 9: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

14. ASelectInterpreterwindowshouldpopup.YouneedtodirectEclipsetothelocation

ofyourPython3librariesandpackages.InthetextboxforInterpreterExecutable,typeoutthefilelocation(andfilename)whereyou’vesavedPython.(ForMacOSXusers,thisistypically/usr/local/bin/Python3.7.ForWindowsusers,recallwhereyou’vesavedPythonfromearlier.).IntheInterpreterNametextbox,giveyourinterpreteraname(Python37wouldbeaneasyandobviouschoice).

15. ClickOKwhenawindowtitledSelectionneededpopsup.

16. Whenyou’vereturnedtothePreferenceswindow,itshouldlookvaguelyliketheimagebelow.ClickApplyandClosewhenyou’reready.

Page 10: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

17. Youshouldbebacktotheinitialworkspacewindownow,andyouhaveEclipseandPyDevproperlyconfigured!Tomakesureeverythingisinworkingorder(andgetyousomeinitialinteractionwithEclipse),let’scodeupandrunabasicPythonprogram…

18. Inthetopribbon,selectFile>New>Project.SelectPyDev>PyDevProjectintheresultingwindow.ThenclickNext>.

19. Createanewprojectwiththename“FirstPythonProj”.MakesuretocheckthelowerboxforCreate‘src’folderandaddittothePYTHONPATH.ThenpressFinish.

Page 11: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

20. Awindowmightpopup;clickOpenPerspective.ThissetsthePyDevperspectiveforthisproject.

21. Toopenaworkspace(ifyouhaven’talready),gotothetopribbonandselectWindow>NewWindow.Intheleftmenuoftheresultingplatform,rightclickonthesrcfolderoftheprojectandselectNew>PyDevModule.Itshouldlooklike:

Page 12: Installing Python and Eclipse on your PC · Click down PyDev > Interpreters > Python Interpreters. In the top right corner of the resulting window, you should have a Browse for Python/pypy

22. Createamodulecalled“FirstModule”.ClickFinishonceyou’venamedit.Ifanyadditionalboxespopuphere,justclickOK.

23. Createsourcecode(ontheright)thatreadslikethis:

24. Rightclickonyourmodelinthelefthandmenu(FirstModule.py)andselectRunAs>

PythonRun.Alternatively,clickthebuttononthetopmenuthatlookslike .

25. Ifyouseethefollowingresultsinyourconsole(bottomofworkspace),congrats!You’regoodtogo.