|
| 1 | +.. _install3-windows: |
| 2 | + |
| 3 | +Installing Python 3 on Windows |
| 4 | +============================ |
| 5 | + |
| 6 | +First, download the `latest version <https://www.python.org/ftp/python/3.6.0/python-3.6.0.exe>`_ |
| 7 | +of Python 3.6 from the official website. If you want to be sure you are installing a fully |
| 8 | +up-to-date version, click the Downloads > Windows link from the home page of the |
| 9 | +`Python.org web site <http://python.org>`_ . |
| 10 | + |
| 11 | +By design, Python installs to a directory with the version number embedded, |
| 12 | +e.g. Python version 3.6 will install at :file:`C:\\Python36\\`, so that you can |
| 13 | +have multiple versions of Python on the |
| 14 | +same system without conflicts. Of course, only one interpreter can be the |
| 15 | +default application for Python file types. It also does not automatically |
| 16 | +modify the :envvar:`PATH` environment variable, so that you always have control over |
| 17 | +which copy of Python is run. |
| 18 | + |
| 19 | +Typing the full path name for a Python interpreter each time quickly gets |
| 20 | +tedious, so add the directories for your default Python version to the :envvar:`PATH`. |
| 21 | +Assuming that your Python installation is in :file:`C:\\Python36\\`, add this to your |
| 22 | +:envvar:`PATH`: |
| 23 | + |
| 24 | +.. code-block:: console |
| 25 | +
|
| 26 | + C:\Python36\;C:\Python36\Scripts\ |
| 27 | +
|
| 28 | +You can do this easily by running the following in ``powershell``: |
| 29 | + |
| 30 | +.. code-block:: console |
| 31 | +
|
| 32 | + [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User") |
| 33 | +
|
| 34 | +This is also an option during the installation process. |
| 35 | + |
| 36 | +The second (:file:`Scripts`) directory receives command files when certain |
| 37 | +packages are installed, so it is a very useful addition. |
| 38 | +You do not need to install or configure anything else to use Python. Having |
| 39 | +said that, I would strongly recommend that you install the tools and libraries |
| 40 | +described in the next section before you start building Python applications for |
| 41 | +real-world use. In particular, you should always install Setuptools, as it |
| 42 | +makes it much easier for you to use other third-party Python libraries. |
| 43 | + |
| 44 | +Setuptools + Pip |
| 45 | +---------------- |
| 46 | + |
| 47 | +The most crucial third-party Python software of all is Setuptools, which |
| 48 | +extends the packaging and installation facilities provided by the distutils in |
| 49 | +the standard library. Once you add Setuptools to your Python system you can |
| 50 | +download and install any compliant Python software product with a single |
| 51 | +command. It also enables you to add this network installation capability to |
| 52 | +your own Python software with very little work. |
| 53 | + |
| 54 | +To obtain the latest version of Setuptools for Windows, run the Python script |
| 55 | +available here: `ez_setup.py <https://bootstrap.pypa.io/ez_setup.py>`_ |
| 56 | + |
| 57 | + |
| 58 | +You'll now have a new command available to you: **easy_install**. It is |
| 59 | +considered by many to be deprecated, so we will install its replacement: |
| 60 | +**pip**. Pip allows for uninstallation of packages, and is actively maintained, |
| 61 | +unlike easy_install. |
| 62 | + |
| 63 | +To install pip, run the Python script available here: |
| 64 | +`get-pip.py <https://raw.github.com/pypa/pip/master/contrib/get-pip.py>`_ |
| 65 | + |
| 66 | + |
| 67 | +Virtual Environments |
| 68 | +-------------------- |
| 69 | + |
| 70 | +A Virtual Environment is a tool to keep the dependencies required by different projects |
| 71 | +in separate places, by creating virtual Python environments for them. It solves the |
| 72 | +"Project X depends on version 1.x but, Project Y needs 4.x" dilemma, and keeps |
| 73 | +your global site-packages directory clean and manageable. |
| 74 | + |
| 75 | +For example, you can work on a project which requires Django 1.10 while also |
| 76 | +maintaining a project which requires Django 1.8. |
| 77 | + |
| 78 | +To start using this and see more information: :ref:`Virtual Environments <virtualenvironments-ref>` docs. |
| 79 | + |
| 80 | + |
| 81 | +-------------------------------- |
| 82 | + |
| 83 | +This page is a remixed version of `another guide <http://www.stuartellis.eu/articles/python-development-windows/>`_, |
| 84 | +which is available under the same license. |
0 commit comments