installation.asciidoc 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. [[installation]]
  2. == Installation
  3. When we refer to "Python 2" in this book, we will be referring to any version of Python equal to or
  4. greater than version https://www.python.org/downloads/[*2.7*].
  5. [[install_windows]]
  6. === Installation on Windows
  7. Visit https://www.python.org/downloads/ and download the latest version. The installation is just
  8. like any other Windows-based software.
  9. CAUTION: When you are given the option of unchecking any "optional" components, don't uncheck any.
  10. [[dos_prompt]]
  11. ==== DOS Prompt
  12. If you want to be able to use Python from the Windows command line i.e. the DOS prompt, then you
  13. need to set the PATH variable appropriately.
  14. For Windows 2000, XP, 2003 , click on +Control Panel+ -> +System+ -> +Advanced+ -> +Environment
  15. Variables+. Click on the variable named +PATH+ in the _System Variables_ section, then select
  16. +Edit+ and add `;C:\Python27` (please verify that this folder exists, it will be different for
  17. newer versions of Python) to the end of what is already there. Of course, use the appropriate
  18. directory name.
  19. For older versions of Windows, open the file `C:\AUTOEXEC.BAT` and add the line
  20. `PATH=%PATH%;C:\Python33` and restart the system. For Windows NT, use the +AUTOEXEC.NT+ file.
  21. For Windows Vista:
  22. . Click Start and choose +Control Panel+
  23. . Click System, on the right you'll see "View basic information about your computer"
  24. . On the left is a list of tasks, the last of which is +Advanced system settings+. Click that.
  25. . The +Advanced+ tab of the +System Properties+ dialog box is shown. Click the +Environment
  26. Variables+ button on the bottom right.
  27. . In the lower box titled +System Variables+ scroll down to Path and click the +Edit+ button.
  28. . Change your path as need be.
  29. . Restart your system. Vista didn't pick up the system path environment variable change until I
  30. restarted.
  31. For Windows 7:
  32. . Right click on Computer from your desktop and select +Properties+ or click +Start+ and choose
  33. +Control Panel+ -> +System and Security+ -> +System+. Click on +Advanced system settings+ on the
  34. left and then click on the +Advanced+ tab. At the bottom click on +Environment Variables+ and under
  35. +System variables+, look for the +PATH+ variable, select and then press +Edit+.
  36. . Go to the end of the line under Variable value and append `;C:\Python33`.
  37. . If the value was `%SystemRoot%\system32;` It will now become `%SystemRoot%\system32;C:\Python33`
  38. . Click +OK+ and you are done. No restart is required.
  39. ==== Running Python prompt on Windows
  40. For Windows users, you can run the interpreter in the command line if you have <<dos_prompt,set the
  41. `PATH` variable appropriately>>.
  42. To open the terminal in Windows, click the start button and click +Run+. In the dialog box, type
  43. +cmd+ and press kbd:[enter] key.
  44. Then, type +python+ and ensure there are no errors.
  45. [[install_osx]]
  46. === Installation on Mac OS X
  47. For Mac OS X users, Python must be installed already.
  48. To verify, open the terminal by pressing kbd:[Command + Space] keys (to open Spotlight search),
  49. type +Terminal+ and press kbd:[enter] key. Now, run +python+ and ensure there are no errors.
  50. [[install_linux]]
  51. === Installation on GNU/Linux
  52. For GNU/Linux users, Python must be installed already.
  53. To verify, open the terminal by opening the +Terminal+ application or by pressing kbd:[Alt + F2]
  54. and entering +gnome-terminal+. If that doesn't work, please refer the documentation of your
  55. particular GNU/Linux distribution. Now, run +python+ and ensure there are no errors.
  56. You can see the version of Python on the screen by running:
  57. --------------------------------------------------
  58. $ python -V
  59. Python 2.7.6
  60. --------------------------------------------------
  61. NOTE: `$` is the prompt of the shell. It will be different for you depending on the settings of the
  62. operating system on your computer, hence I will indicate the prompt by just the `$` symbol.
  63. CAUTION: Output may be different on your computer, depending on the version of Python software
  64. installed on your computer.
  65. === Summary
  66. From now on, we will assume that you have Python installed on your system.
  67. Next, we will write our first Python program.