{"id":19,"date":"2014-10-17T17:00:36","date_gmt":"2014-10-17T21:00:36","guid":{"rendered":"http:\/\/pfsensesetup.com\/pythonscript.net\/?p=19"},"modified":"2014-10-17T15:12:56","modified_gmt":"2014-10-17T19:12:56","slug":"install-python","status":"publish","type":"post","link":"http:\/\/pfsensesetup.com\/pythonscript.net\/install-python\/","title":{"rendered":"How to Install Python"},"content":{"rendered":"<div id=\"attachment_20\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img01.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-20\" class=\"size-medium wp-image-20\" src=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img01-300x151.png\" alt=\"Install Python\" width=\"300\" height=\"151\" srcset=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img01-300x151.png 300w, http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img01.png 677w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-20\" class=\"wp-caption-text\">Running the Python command line.<\/p><\/div>\n<p>If you want to run a Python script and you don&#8217;t have Python on your system already, fear not. There are a number of options available to install Python, covering a wide variety of different platforms.<\/p>\n<h3><span style=\"text-decoration: underline;\"><strong>How to Install Python: From python.o<\/strong><\/span><span style=\"text-decoration: underline;\"><strong>rg<\/strong><\/span><\/h3>\n<p>Probably the easiest way to install Python is to go to the official Python site&#8217;s download page (http:\/\/www.python.org\/downloads\/). Select the release version you want to download, and select the appropriate operating system. The source is also available as a gzipped tarball. If you are running Linux, you may already have Python installed. Ubuntu, for example, includes Python by default. If not, you should be able to install Python from the repositories by typing:<\/p>\n<p><strong>sudo apt-get install python<\/strong><\/p>\n<p>When prompted, type the superuser password, and installation will begin.<\/p>\n<div id=\"attachment_21\" style=\"width: 294px\" class=\"wp-caption alignright\"><a href=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img02.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21\" class=\"size-medium wp-image-21\" src=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img02-284x300.png\" alt=\"Install Python\" width=\"284\" height=\"300\" srcset=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img02-284x300.png 284w, http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img02.png 685w\" sizes=\"auto, (max-width: 284px) 100vw, 284px\" \/><\/a><p id=\"caption-attachment-21\" class=\"wp-caption-text\">IDLE, the official Python GUI.<\/p><\/div>\n<p>Once Python is installed, you should be able to invoke the Python interpreter at the command line by typing &#8220;<strong>python<\/strong>&#8220;. Alternatively, you can create a shortcut for Python on your desktop and click on the icon. Clicking on &#8220;<strong>pythonw<\/strong>&#8221; should start IDLE, the Python GUI. You may, however, have problems running IDLE on certain versions of Windows. I myself could not start pythonw under Windows 8.1. If you have the same problem, you might consider using an alternative method for starting IDLE:<\/p>\n<ol>\n<li>Start the Python command line. You can do this [1] by launching a command prompt and typing &#8220;<strong>python<\/strong>&#8220;; [2] by double-clicking &#8220;<strong>python.exe<\/strong>&#8221; in the File Explorer; [3] by right-mouse clicking on the Windows logo in the lower left corner of the desktop, selecting &#8220;<strong>Run<\/strong>&#8221; and launching python.exe from &#8220;<strong>Run<\/strong>&#8220;, or [4] creating a desktop icon for Python and clicking on it.<\/li>\n<li>In the Python interpreter, type &#8220;<strong>import idlelib.idle<\/strong>&#8221; and press <strong>&lt;ENTER&gt;<\/strong>. IDLE should now launch.<\/li>\n<\/ol>\n<p>Whether you are using the basic Python command interpreter or IDLE, you can start typing in Python code. Typing and executing the Python Hello World program is almost trivial:<\/p>\n<p><strong>&gt;&gt;&gt; print(&#8216;Hello, world!&#8217;)<\/strong><br \/>\n<strong> Hello, world!<\/strong><\/p>\n<p>As you can see, the Python interpreter runs the program without the need to compile the code, one of the advantages of using Python. Using IDLE provides the following advantages over the standard Python shell:<\/p>\n<ul>\n<li>The ability to save and load Python source code files<\/li>\n<li>The ability to cut, copy and paste text, and search<\/li>\n<li>The ability to debug programs, using IDLE&#8217;s debugger and stack viewer<\/li>\n<\/ul>\n<h3><span style=\"text-decoration: underline;\"><strong>How to Install Python: The Eclipse IDE<\/strong><\/span><\/h3>\n<div id=\"attachment_22\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img03.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22\" class=\"size-medium wp-image-22\" src=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img03-300x231.png\" alt=\"Install Python\" width=\"300\" height=\"231\" srcset=\"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img03-300x231.png 300w, http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img03-1024x790.png 1024w, http:\/\/pfsensesetup.com\/pythonscript.net\/wp-content\/uploads\/2014\/10\/runningpython_img03.png 1296w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-22\" class=\"wp-caption-text\">Using the PyDev plugin in the Eclipse IDE to write and run a Python script.<\/p><\/div>\n<p>Many users will likely find the stock Python installation more than adequate. For those looking for a more elegant solution, however, I suggest the Eclipse IDE. Eclipse is an integrated development environment originally developed by IBM Canada, and currently being developed by the Eclipse Foundation. It contains a base workspace and an extensible plug-in system for customizing the environment. The base system is only useful for Java development, but with plug-ins, you can extend Eclipse to develop applications in other programming languages, including C\/C++, COBOL, JavaScript, Perl, PHP &#8211; and Python.<\/p>\n<p>The official Eclipse website can be found at eclipse.org; here you can download the latest version. As of this writing, the current version is 4.4, and there are versions for Windows (32 and 64-bit), Linux and Mac OS X. Under Linux, you can also install Eclipse from the repositories by typing:<\/p>\n<p><strong>sudo apt-get install eclipse<\/strong><\/p>\n<p>and typing the superuser password when prompted.<\/p>\n<p>Once Eclipse is installed, you still need to install the Python plugin. I use the PyDev Python IDE for Eclipse, which you can find at: <a href=\"http:\/\/marketplace.eclipse.org\/content\/pydev-python-ide-eclipse\">http:\/\/marketplace.eclipse.org\/content\/pydev-python-ide-eclipse<\/a>. Some of the features of PyDev include:<\/p>\n<ul>\n<li>Python, Jython and IronPython support<\/li>\n<li>Django integration<\/li>\n<li>Code completion<\/li>\n<li>A debugger<\/li>\n<li>Code analysis<\/li>\n<\/ul>\n<p>To install PyDev, launch Eclipse, and from the top menu, navigate to Help -&gt; Install New Software to launch the Install New Software dialog box. In the &#8220;Work with: &#8221; edit box at the top, type:<\/p>\n<p><strong>PyDev and PyDev Extensions &#8211; http:\/\/pydev.org\/updates<\/strong><\/p>\n<p>and press the &#8220;<strong>Add<\/strong>&#8221; button. &#8220;<strong>PyDev<\/strong>&#8221; and &#8220;<strong>PyDev Mylyn Integration (optional)<\/strong>&#8221; should appear in the list box. Check the software packages you want to install (PyDev is required if you want to use PyDev to use Python with Eclipse; Mylyn is an optional application lifecycle management framework that serves as a task management tool for Eclipse). When you have made your selection, press the &#8220;Next&#8221; button; it should take a minute for Eclipse to calculate file sizes and dependencies. Review the information on the next page and press &#8220;<strong>Next<\/strong>&#8221; again. On the subsequent page, click on the radio button to agree to the software license terms and press &#8220;<strong>Finish<\/strong>&#8220;. PyDev should now be installed.<\/p>\n<p>Now, you should be able to start a Python project in Eclipse by navigating to <strong>File<\/strong> -&gt; <strong>New<\/strong> -&gt; <strong>PyDev Project<\/strong>. You need to give your project a name, and select a grammar version (default is 2.7), but it should be easy to create a project. Once you have created a project, you can right-mouse click on the project, and select New -&gt; File to create a new Python source code file that will be added to the project.<\/p>\n<p>Although I covered how to install Python using the stock Python installation as well as Eclipse in this article, I barely scratched the surface in terms of what is available for Python development. I prefer Eclipse, but it may behoove you to do your own research and find the tools which best fit your needs.<\/p>\n<h3><span style=\"text-decoration: underline;\"><strong>External Links:<\/strong><\/span><\/h3>\n<p><a href=\"http:\/\/python.org\">The official Python site<\/a><\/p>\n<p><a href=\"http\/\/www.eclipse.org\">The official Eclipse site<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to run a Python script and you don&#8217;t have Python on your system already, fear not. There are a number of options available to install Python, covering a wide variety of different platforms. How to Install Python: From python.org Probably the easiest way to install Python is to go to the official [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,7,3],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-general","category-guides","category-tutorials","entry"],"_links":{"self":[{"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":2,"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":24,"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/posts\/19\/revisions\/24"}],"wp:attachment":[{"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pfsensesetup.com\/pythonscript.net\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}