Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 1 | .. highlightlang:: none |
| 2 | |
| 3 | .. _using-on-windows: |
| 4 | |
| 5 | ************************* |
| 6 | Using Python on Windows |
| 7 | ************************* |
| 8 | |
| 9 | .. sectionauthor:: Robert Lehmann <lehmannro@gmail.com> |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 10 | .. sectionauthor:: Steve Dower <steve.dower@microsoft.com> |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 11 | |
| 12 | This document aims to give an overview of Windows-specific behaviour you should |
| 13 | know about when using Python on Microsoft Windows. |
| 14 | |
Larry Hastings | 3732ed2 | 2014-03-15 21:13:56 -0700 | [diff] [blame] | 15 | .. XXX (ncoghlan) |
| 16 | |
| 17 | This looks rather stale to me... |
| 18 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 19 | |
| 20 | Installing Python |
| 21 | ================= |
| 22 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 23 | Unlike most Unix systems and services, Windows does not include a system |
| 24 | supported installation of Python. To make Python available, the CPython team |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 25 | has compiled Windows installers (MSI packages) with every `release |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 26 | <https://www.python.org/download/releases/>`_ for many years. These installers |
| 27 | are primarily intended to add a system-wide installation of Python, with the |
| 28 | core interpreter and library being shared by all application. Non-shared |
| 29 | layouts of the Python interpreter may also be created with the same installer, |
| 30 | however, the released installer is not intended for embedding in other |
| 31 | installers. |
| 32 | |
| 33 | Installation Steps |
| 34 | ------------------ |
| 35 | |
| 36 | Four Python 3.5 installers are available for download - two each for the 32-bit |
| 37 | and 64-bit versions of the interpreter. The *web installer* is a small initial |
| 38 | download, and it will automatically download the required components as |
| 39 | necessary. The *offline installer* includes the components necessary for a |
| 40 | default installation and only requires an internet connection for optional |
| 41 | features. See :ref:`install-layout-option` for other ways to avoid downloading |
| 42 | during installation. |
| 43 | |
| 44 | After starting the installer, one of three options may be selected: |
| 45 | |
| 46 | .. image:: win_installer.png |
| 47 | |
| 48 | If you select "Install for All Users": |
| 49 | |
| 50 | * You may be required to provide administrative credentials or approval |
| 51 | * Python will be installed into your Program Files directory |
| 52 | * The :ref:`launcher` will be installed into your Windows directory |
| 53 | * The standard library, test suite, launcher and pip will be installed |
| 54 | * After installation, the standard library will be pre-compiled to bytecode |
| 55 | * If selected, the install directory will be added to :envvar:`PATH` |
| 56 | |
| 57 | If you select "Install Just for Me": |
| 58 | |
| 59 | * You will *not* need to be an administrator |
| 60 | * Python will be installed into your user directory |
| 61 | * The :ref:`launcher` will *also* be installed into your user directory |
| 62 | * The standard library, test suite, launcher and pip will be installed |
| 63 | * If selected, the install directory will be added to :envvar:`PATH` |
| 64 | |
| 65 | Selecting "Customize installation" will allow you to select the features to |
| 66 | install, the installation location and other options or post-install actions. |
| 67 | To install debugging symbols or binaries, you will need to use this option. |
| 68 | |
| 69 | .. _install-quiet-option: |
| 70 | |
| 71 | Installing Without UI |
| 72 | --------------------- |
| 73 | |
| 74 | All of the options available in the installer UI can also be specified from the |
| 75 | command line, allowing scripted installers to replicate an installation on many |
| 76 | machines without user interaction. These options may also be set without |
| 77 | suppressing the UI in order to change some of the defaults. |
| 78 | |
| 79 | To completely hide the installer UI and install Python silently, pass the |
| 80 | ``/quiet`` (``/q``) option. To skip past the user interaction but still display |
| 81 | progress and errors, pass the ``/passive`` (``/p``) option. The ``/uninstall`` |
| 82 | option may be passed to immediately begin removing Python - no prompt will be |
| 83 | displayed. |
| 84 | |
| 85 | All other options are passed as ``name=value``, where the value is usually |
| 86 | ``0`` to disable a feature, ``1`` to enable a feature, or a path. The full list |
| 87 | of available options is shown below. |
| 88 | |
| 89 | +---------------------------+--------------------------------------+--------------------------+ |
| 90 | | Name | Description | Default | |
| 91 | +===========================+======================================+==========================+ |
| 92 | | InstallAllUsers | Perform a system-wide installation. | 1 | |
| 93 | +---------------------------+--------------------------------------+--------------------------+ |
| 94 | | TargetDir | The installation directory | Selected based on | |
| 95 | | | | InstallAllUsers | |
| 96 | +---------------------------+--------------------------------------+--------------------------+ |
| 97 | | DefaultAllUsersTargetDir | The default installation directory | :file:`%ProgramFiles%\\\ | |
| 98 | | | for all-user installs | Python X.Y` or :file:`\ | |
| 99 | | | | %ProgramFiles(x86)%\\\ | |
| 100 | | | | Python X.Y` | |
| 101 | +---------------------------+--------------------------------------+--------------------------+ |
| 102 | | DefaultJustForMeTargetDir | The default install directory for | :file:`%LocalAppData%\\\ | |
| 103 | | | just-for-me installs | Programs\\PythonXY` or | |
| 104 | | | | :file:`%LocalAppData%\\\ | |
| 105 | | | | Programs\\PythonXY-32` | |
| 106 | +---------------------------+--------------------------------------+--------------------------+ |
| 107 | | DefaultCustomTargetDir | The default custom install directory | (empty) | |
| 108 | | | displayed in the UI | | |
| 109 | +---------------------------+--------------------------------------+--------------------------+ |
| 110 | | AssociateFiles | Create file associations if the | 1 | |
| 111 | | | launcher is also installed. | | |
| 112 | +---------------------------+--------------------------------------+--------------------------+ |
| 113 | | CompileAll | Compile all ``.py`` files to | 0 | |
| 114 | | | ``.pyc`` and ``.pyo``. | | |
| 115 | +---------------------------+--------------------------------------+--------------------------+ |
| 116 | | PrependPath | Add install and Scripts directories | 0 | |
| 117 | | | tho :envvar:`PATH` and ``.PY`` to | | |
| 118 | | | :envvar:`PATHEXT` | | |
| 119 | +---------------------------+--------------------------------------+--------------------------+ |
| 120 | | Include_doc | Install Python manual | 1 | |
| 121 | +---------------------------+--------------------------------------+--------------------------+ |
| 122 | | Include_debug | Install debug binaries | 0 | |
| 123 | +---------------------------+--------------------------------------+--------------------------+ |
| 124 | | Include_dev | Install developer headers and | 1 | |
| 125 | | | libraries | | |
| 126 | +---------------------------+--------------------------------------+--------------------------+ |
| 127 | | Include_exe | Install :file:`python.exe` and | 1 | |
| 128 | | | related files | | |
| 129 | +---------------------------+--------------------------------------+--------------------------+ |
| 130 | | Include_launcher | Install :ref:`launcher`. | 1 | |
| 131 | +---------------------------+--------------------------------------+--------------------------+ |
| 132 | | Include_lib | Install standard library and | 1 | |
| 133 | | | extension modules | | |
| 134 | +---------------------------+--------------------------------------+--------------------------+ |
| 135 | | Include_pip | Install bundled pip and setuptools | 1 | |
| 136 | +---------------------------+--------------------------------------+--------------------------+ |
| 137 | | Include_symbols | Install debugging symbols (`*`.pdb) | 0 | |
| 138 | +---------------------------+--------------------------------------+--------------------------+ |
| 139 | | Include_tcltk | Install Tcl/Tk support and IDLE | 1 | |
| 140 | +---------------------------+--------------------------------------+--------------------------+ |
| 141 | | Include_test | Install standard library test suite | 1 | |
| 142 | +---------------------------+--------------------------------------+--------------------------+ |
| 143 | | Include_tools | Install utility scripts | 1 | |
| 144 | +---------------------------+--------------------------------------+--------------------------+ |
| 145 | | SimpleInstall | Disable most install UI | 0 | |
| 146 | +---------------------------+--------------------------------------+--------------------------+ |
| 147 | |
| 148 | For example, to silently install a default, system-wide Python installation, |
| 149 | you could use the following command (from an elevated command prompt):: |
| 150 | |
| 151 | python-3.5.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 |
| 152 | |
| 153 | To allow users to easily install a personal copy of Python without the test |
| 154 | suite, you could provide a shortcut with the following command:: |
| 155 | |
| 156 | python-3.5.0.exe /passive InstallAllUsers=0 Include_launcher=0 Include_test=0 SimpleInstall=1 |
| 157 | |
| 158 | (Note that omitting the launcher also omits file associations, and is only |
| 159 | recommended for per-user installs when there is also a system-wide installation |
| 160 | that included the launcher.) |
| 161 | |
| 162 | .. _install-layout-option: |
| 163 | |
| 164 | Installing Without Downloading |
| 165 | ------------------------------ |
| 166 | |
| 167 | As some features of Python are not included in the initial installer download, |
| 168 | selecting those features may require an internet connection. To avoid this |
| 169 | need, all possible components may be downloaded on-demand to create a complete |
| 170 | *layout* that will no longer require an internet connection regardless of the |
| 171 | selected features. Note that this download may be bigger than required, but |
| 172 | where a large number of installations are going to be performed it is very |
| 173 | useful to have a locally cached copy. |
| 174 | |
| 175 | Execute the following command from Command Prompt to download all possible |
| 176 | required files. Remember to substitute ``python-3.5.0.exe`` for the actual |
| 177 | name of your installer, and to create layouts in their own directories to |
| 178 | avoid collisions between files with the same name. |
| 179 | |
| 180 | :: |
| 181 | |
| 182 | python-3.5.0.exe /layout [optional target directory] |
| 183 | |
| 184 | You may also specify the ``/quiet`` option to hide the progress display. |
| 185 | |
| 186 | |
| 187 | Other Platforms |
| 188 | --------------- |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 189 | |
| 190 | With ongoing development of Python, some platforms that used to be supported |
Christian Heimes | 380f7f2 | 2008-02-28 11:19:05 +0000 | [diff] [blame] | 191 | earlier are no longer supported (due to the lack of users or developers). |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 192 | Check :pep:`11` for details on all unsupported platforms. |
| 193 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 194 | * `Windows CE <http://pythonce.sourceforge.net/>`_ is still supported. |
Georg Brandl | 525d355 | 2014-10-29 10:26:56 +0100 | [diff] [blame] | 195 | * The `Cygwin <http://cygwin.com/>`_ installer offers to install the Python |
| 196 | interpreter as well (cf. `Cygwin package source |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 197 | <ftp://ftp.uni-erlangen.de/pub/pc/gnuwin32/cygwin/mirrors/cygnus/ |
| 198 | release/python>`_, `Maintainer releases |
| 199 | <http://www.tishler.net/jason/software/python/>`_) |
| 200 | |
Georg Brandl | e73778c | 2014-10-29 08:36:35 +0100 | [diff] [blame] | 201 | See `Python for Windows <https://www.python.org/download/windows/>`_ |
Zachary Ware | c3cf97b | 2014-01-17 15:23:42 -0600 | [diff] [blame] | 202 | for detailed information about platforms with pre-compiled installers. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 203 | |
| 204 | .. seealso:: |
| 205 | |
| 206 | `Python on XP <http://www.richarddooling.com/index.php/2006/03/14/python-on-xp-7-minutes-to-hello-world/>`_ |
| 207 | "7 Minutes to "Hello World!"" |
| 208 | by Richard Dooling, 2006 |
| 209 | |
Georg Brandl | 525d355 | 2014-10-29 10:26:56 +0100 | [diff] [blame] | 210 | `Installing on Windows <http://www.diveintopython.net/installing_python/windows.html>`_ |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 211 | in "`Dive into Python: Python from novice to pro |
Georg Brandl | 525d355 | 2014-10-29 10:26:56 +0100 | [diff] [blame] | 212 | <http://www.diveintopython.net/>`_" |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 213 | by Mark Pilgrim, 2004, |
| 214 | ISBN 1-59059-356-1 |
| 215 | |
Georg Brandl | fe85807 | 2014-10-28 23:00:25 +0100 | [diff] [blame] | 216 | `For Windows users <http://www.swaroopch.com/notes/python/#install_windows>`_ |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 217 | in "Installing Python" |
Georg Brandl | fe85807 | 2014-10-28 23:00:25 +0100 | [diff] [blame] | 218 | in "`A Byte of Python <http://www.swaroopch.com/notes/python/>`_" |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 219 | by Swaroop C H, 2003 |
| 220 | |
| 221 | |
| 222 | Alternative bundles |
| 223 | =================== |
| 224 | |
| 225 | Besides the standard CPython distribution, there are modified packages including |
| 226 | additional functionality. The following is a list of popular versions and their |
| 227 | key features: |
| 228 | |
Zachary Ware | c3cf97b | 2014-01-17 15:23:42 -0600 | [diff] [blame] | 229 | `ActivePython <http://www.activestate.com/activepython/>`_ |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 230 | Installer with multi-platform compatibility, documentation, PyWin32 |
| 231 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 232 | `Anaconda <http://www.continuum.io/downloads/>`_ |
| 233 | Popular scientific modules (such as numpy, scipy and pandas) and the |
| 234 | ``conda`` package manager. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 235 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 236 | `Canopy <https://www.enthought.com/products/canopy/>`_ |
| 237 | A "comprehensive Python analysis environment" with editors and other |
| 238 | development tools. |
| 239 | |
| 240 | `WinPython <https://winpython.github.io/>`_ |
| 241 | Windows-specific distribution with prebuilt scientific packages and |
| 242 | tools for building packages. |
| 243 | |
| 244 | Note that these packages may not include the latest versions of Python or |
| 245 | other libraries, and are not maintained or supported by the core Python team. |
Christian Heimes | 255f53b | 2007-12-08 15:33:56 +0000 | [diff] [blame] | 246 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 247 | |
| 248 | |
| 249 | Configuring Python |
| 250 | ================== |
| 251 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 252 | To run Python conveniently from a command prompt, you might consider changing |
| 253 | some default environment variables in Windows. While the installer provides an |
| 254 | option to configure the PATH and PATHEXT variables for you, this is only |
| 255 | reliable for a single, system-wide installation. If you regularly use multiple |
| 256 | versions of Python, consider using the :ref:`launcher`. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 257 | |
| 258 | |
Brian Curtin | a86f185 | 2012-08-19 11:22:20 -0500 | [diff] [blame] | 259 | .. _setting-envvars: |
| 260 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 261 | Excursus: Setting environment variables |
| 262 | --------------------------------------- |
| 263 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 264 | Windows allows environment variables to be configured permanently at both the |
| 265 | User level and the System level, or temporarily in a command prompt. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 266 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 267 | To temporarily set environment variables, open Command Prompt and use the |
| 268 | :command:`set` command:: |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 269 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 270 | C:\>set PATH=C:\Program Files\Python 3.5;%PATH% |
| 271 | C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib |
| 272 | C:\>python |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 273 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 274 | These changes will apply to any further commands executed in that console, and |
| 275 | will be inherited by any applications started from the console. |
| 276 | |
| 277 | Including the variable name within percent signs will expand to the existing |
| 278 | value, allowing you to add your new value at either the start or the end. |
| 279 | Modifying :envvar:`PATH` by adding the directory containing |
| 280 | :program:`python.exe` to the start is a common way to ensure the correct version |
| 281 | of Python is launched. |
| 282 | |
| 283 | To permanently modify the default environment variables, click Start and search |
| 284 | for 'edit environment variables', or open System properties, :guilabel:`Advanced |
| 285 | system settings` and click the :guilabel:`Environment Variables` button. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 286 | In this dialog, you can add or modify User and System variables. To change |
| 287 | System variables, you need non-restricted access to your machine |
| 288 | (i.e. Administrator rights). |
| 289 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 290 | .. note:: |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 291 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 292 | Windows will concatenate User variables *after* System variables, which may |
| 293 | cause unexpected results when modifying :envvar:`PATH`. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 294 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 295 | The :envvar:`PYTHONPATH` variable is used by all versions of Python 2 and |
| 296 | Python 3, so you should not permanently configure this variable unless it |
| 297 | only includes code that is compatible all of your installed Python |
| 298 | versions. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 299 | |
| 300 | .. seealso:: |
| 301 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 302 | http://support.microsoft.com/kb/100843 |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 303 | Environment variables in Windows NT |
| 304 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 305 | http://technet.microsoft.com/en-us/library/cc754250.aspx |
| 306 | The SET command, for temporarily modifying environment variables |
| 307 | |
| 308 | http://technet.microsoft.com/en-us/library/cc755104.aspx |
| 309 | The SETX command, for permanently modifying environment variables |
| 310 | |
| 311 | http://support.microsoft.com/kb/310519 |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 312 | How To Manage Environment Variables in Windows XP |
| 313 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 314 | http://www.chem.gla.ac.uk/~louis/software/faq/q1.html |
Christian Heimes | 255f53b | 2007-12-08 15:33:56 +0000 | [diff] [blame] | 315 | Setting Environment variables, Louis J. Farrugia |
| 316 | |
Nick Coghlan | 349c802 | 2012-09-30 13:00:43 +0530 | [diff] [blame] | 317 | .. _windows-path-mod: |
| 318 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 319 | Finding the Python executable |
| 320 | ----------------------------- |
| 321 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 322 | .. versionchanged:: 3.5 |
Brian Curtin | a86f185 | 2012-08-19 11:22:20 -0500 | [diff] [blame] | 323 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 324 | Besides using the automatically created start menu entry for the Python |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 325 | interpreter, you might want to start Python in the command prompt. The |
| 326 | installer for Python 3.5 and later has an option to set that up for you. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 327 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 328 | On the first page of the installer, an option labelled "Add Python 3.5 to |
| 329 | PATH" can be selected to have the installer add the install location into the |
| 330 | :envvar:`PATH`. The location of the :file:`Scripts\\` folder is also added. |
| 331 | This allows you to type :command:`python` to run the interpreter, and |
| 332 | :command:`pip` or . Thus, you can also execute your |
Brian Curtin | a86f185 | 2012-08-19 11:22:20 -0500 | [diff] [blame] | 333 | scripts with command line options, see :ref:`using-on-cmdline` documentation. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 334 | |
Brian Curtin | a86f185 | 2012-08-19 11:22:20 -0500 | [diff] [blame] | 335 | If you don't enable this option at install time, you can always re-run the |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 336 | installer, select Modify, and enable it. Alternatively, you can manually |
| 337 | modify the :envvar:`PATH` using the directions in :ref:`setting-envvars`. You |
| 338 | need to set your :envvar:`PATH` environment variable to include the directory |
| 339 | of your Python installation, delimited by a semicolon from other entries. An |
| 340 | example variable could look like this (assuming the first two entries already |
| 341 | existed):: |
Brian Curtin | a86f185 | 2012-08-19 11:22:20 -0500 | [diff] [blame] | 342 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 343 | C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.5 |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 344 | |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 345 | .. _launcher: |
| 346 | |
| 347 | Python Launcher for Windows |
| 348 | =========================== |
| 349 | |
| 350 | .. versionadded:: 3.3 |
| 351 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 352 | The Python launcher for Windows is a utility which aids in locating and |
| 353 | executing of different Python versions. It allows scripts (or the |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 354 | command-line) to indicate a preference for a specific Python version, and |
| 355 | will locate and execute that version. |
| 356 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 357 | Unlike the :envvar:`PATH` variable, the launcher will correctly select the most |
| 358 | appropriate version of Python. It will prefer per-user installations over |
| 359 | system-wide ones, and orders by language version rather than using the most |
| 360 | recently installed version. |
| 361 | |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 362 | Getting started |
| 363 | --------------- |
| 364 | |
| 365 | From the command-line |
| 366 | ^^^^^^^^^^^^^^^^^^^^^ |
| 367 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 368 | System-wide installations of Python 3.3 and later will put the launcher on your |
| 369 | :envvar:`PATH`. The launcher is compatible with all available versions of |
| 370 | Python, so it does not matter which version is installed. To check that the |
| 371 | launcher is available, execute the following command in Command Prompt: |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 372 | |
| 373 | :: |
| 374 | |
| 375 | py |
| 376 | |
| 377 | You should find that the latest version of Python 2.x you have installed is |
| 378 | started - it can be exited as normal, and any additional command-line |
| 379 | arguments specified will be sent directly to Python. |
| 380 | |
| 381 | If you have multiple versions of Python 2.x installed (e.g., 2.6 and 2.7) you |
| 382 | will have noticed that Python 2.7 was started - to launch Python 2.6, try the |
| 383 | command: |
| 384 | |
| 385 | :: |
| 386 | |
| 387 | py -2.6 |
| 388 | |
| 389 | If you have a Python 3.x installed, try the command: |
| 390 | |
| 391 | :: |
| 392 | |
| 393 | py -3 |
| 394 | |
| 395 | You should find the latest version of Python 3.x starts. |
| 396 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 397 | If you see the following error, you do not have the launcher installed: |
| 398 | |
| 399 | :: |
| 400 | |
| 401 | 'py' is not recognized as an internal or external command, |
| 402 | operable program or batch file. |
| 403 | |
| 404 | Per-user installations of Python do not add the launcher to :envvar:`PATH` |
| 405 | unless the option was selected on installation. |
| 406 | |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 407 | From a script |
| 408 | ^^^^^^^^^^^^^ |
| 409 | |
| 410 | Let's create a test Python script - create a file called ``hello.py`` with the |
| 411 | following contents |
| 412 | |
| 413 | :: |
| 414 | |
| 415 | #! python |
| 416 | import sys |
| 417 | sys.stdout.write("hello from Python %s\n" % (sys.version,)) |
| 418 | |
| 419 | From the directory in which hello.py lives, execute the command: |
| 420 | |
| 421 | :: |
| 422 | |
| 423 | py hello.py |
| 424 | |
| 425 | You should notice the version number of your latest Python 2.x installation |
| 426 | is printed. Now try changing the first line to be: |
| 427 | |
| 428 | :: |
| 429 | |
| 430 | #! python3 |
| 431 | |
| 432 | Re-executing the command should now print the latest Python 3.x information. |
| 433 | As with the above command-line examples, you can specify a more explicit |
| 434 | version qualifier. Assuming you have Python 2.6 installed, try changing the |
| 435 | first line to ``#! python2.6`` and you should find the 2.6 version |
| 436 | information printed. |
| 437 | |
| 438 | From file associations |
| 439 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 440 | |
| 441 | The launcher should have been associated with Python files (i.e. ``.py``, |
| 442 | ``.pyw``, ``.pyc``, ``.pyo`` files) when it was installed. This means that |
| 443 | when you double-click on one of these files from Windows explorer the launcher |
| 444 | will be used, and therefore you can use the same facilities described above to |
| 445 | have the script specify the version which should be used. |
| 446 | |
| 447 | The key benefit of this is that a single launcher can support multiple Python |
| 448 | versions at the same time depending on the contents of the first line. |
| 449 | |
| 450 | Shebang Lines |
| 451 | ------------- |
| 452 | |
| 453 | If the first line of a script file starts with ``#!``, it is known as a |
| 454 | "shebang" line. Linux and other Unix like operating systems have native |
| 455 | support for such lines and are commonly used on such systems to indicate how |
| 456 | a script should be executed. This launcher allows the same facilities to be |
| 457 | using with Python scripts on Windows and the examples above demonstrate their |
| 458 | use. |
| 459 | |
| 460 | To allow shebang lines in Python scripts to be portable between Unix and |
| 461 | Windows, this launcher supports a number of 'virtual' commands to specify |
| 462 | which interpreter to use. The supported virtual commands are: |
| 463 | |
| 464 | * ``/usr/bin/env python`` |
| 465 | * ``/usr/bin/python`` |
| 466 | * ``/usr/local/bin/python`` |
| 467 | * ``python`` |
| 468 | |
| 469 | For example, if the first line of your script starts with |
| 470 | |
| 471 | :: |
| 472 | |
| 473 | #! /usr/bin/python |
| 474 | |
| 475 | The default Python will be located and used. As many Python scripts written |
| 476 | to work on Unix will already have this line, you should find these scripts can |
| 477 | be used by the launcher without modification. If you are writing a new script |
| 478 | on Windows which you hope will be useful on Unix, you should use one of the |
| 479 | shebang lines starting with ``/usr``. |
| 480 | |
| 481 | Arguments in shebang lines |
| 482 | -------------------------- |
| 483 | |
| 484 | The shebang lines can also specify additional options to be passed to the |
| 485 | Python interpreter. For example, if you have a shebang line: |
| 486 | |
| 487 | :: |
| 488 | |
| 489 | #! /usr/bin/python -v |
| 490 | |
| 491 | Then Python will be started with the ``-v`` option |
| 492 | |
| 493 | Customization |
| 494 | ------------- |
| 495 | |
| 496 | Customization via INI files |
| 497 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 498 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 499 | Two .ini files will be searched by the launcher - ``py.ini`` in the current |
| 500 | user's "application data" directory (i.e. the directory returned by calling the |
| 501 | Windows function SHGetFolderPath with CSIDL_LOCAL_APPDATA) and ``py.ini`` in the |
| 502 | same directory as the launcher. The same .ini files are used for both the |
| 503 | 'console' version of the launcher (i.e. py.exe) and for the 'windows' version |
| 504 | (i.e. pyw.exe) |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 505 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 506 | Customization specified in the "application directory" will have precedence over |
| 507 | the one next to the executable, so a user, who may not have write access to the |
| 508 | .ini file next to the launcher, can override commands in that global .ini file) |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 509 | |
| 510 | Customizing default Python versions |
| 511 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 512 | |
| 513 | In some cases, a version qualifier can be included in a command to dictate |
| 514 | which version of Python will be used by the command. A version qualifier |
| 515 | starts with a major version number and can optionally be followed by a period |
| 516 | ('.') and a minor version specifier. If the minor qualifier is specified, it |
| 517 | may optionally be followed by "-32" to indicate the 32-bit implementation of |
| 518 | that version be used. |
| 519 | |
| 520 | For example, a shebang line of ``#!python`` has no version qualifier, while |
| 521 | ``#!python3`` has a version qualifier which specifies only a major version. |
| 522 | |
| 523 | If no version qualifiers are found in a command, the environment variable |
| 524 | ``PY_PYTHON`` can be set to specify the default version qualifier - the default |
| 525 | value is "2". Note this value could specify just a major version (e.g. "2") or |
| 526 | a major.minor qualifier (e.g. "2.6"), or even major.minor-32. |
| 527 | |
| 528 | If no minor version qualifiers are found, the environment variable |
| 529 | ``PY_PYTHON{major}`` (where ``{major}`` is the current major version qualifier |
| 530 | as determined above) can be set to specify the full version. If no such option |
| 531 | is found, the launcher will enumerate the installed Python versions and use |
| 532 | the latest minor release found for the major version, which is likely, |
| 533 | although not guaranteed, to be the most recently installed version in that |
| 534 | family. |
| 535 | |
| 536 | On 64-bit Windows with both 32-bit and 64-bit implementations of the same |
| 537 | (major.minor) Python version installed, the 64-bit version will always be |
| 538 | preferred. This will be true for both 32-bit and 64-bit implementations of the |
| 539 | launcher - a 32-bit launcher will prefer to execute a 64-bit Python installation |
| 540 | of the specified version if available. This is so the behavior of the launcher |
| 541 | can be predicted knowing only what versions are installed on the PC and |
| 542 | without regard to the order in which they were installed (i.e., without knowing |
| 543 | whether a 32 or 64-bit version of Python and corresponding launcher was |
| 544 | installed last). As noted above, an optional "-32" suffix can be used on a |
| 545 | version specifier to change this behaviour. |
| 546 | |
| 547 | Examples: |
| 548 | |
| 549 | * If no relevant options are set, the commands ``python`` and |
| 550 | ``python2`` will use the latest Python 2.x version installed and |
| 551 | the command ``python3`` will use the latest Python 3.x installed. |
| 552 | |
| 553 | * The commands ``python3.1`` and ``python2.7`` will not consult any |
| 554 | options at all as the versions are fully specified. |
| 555 | |
| 556 | * If ``PY_PYTHON=3``, the commands ``python`` and ``python3`` will both use |
| 557 | the latest installed Python 3 version. |
| 558 | |
| 559 | * If ``PY_PYTHON=3.1-32``, the command ``python`` will use the 32-bit |
| 560 | implementation of 3.1 whereas the command ``python3`` will use the latest |
| 561 | installed Python (PY_PYTHON was not considered at all as a major |
| 562 | version was specified.) |
| 563 | |
| 564 | * If ``PY_PYTHON=3`` and ``PY_PYTHON3=3.1``, the commands |
| 565 | ``python`` and ``python3`` will both use specifically 3.1 |
| 566 | |
| 567 | In addition to environment variables, the same settings can be configured |
| 568 | in the .INI file used by the launcher. The section in the INI file is |
| 569 | called ``[defaults]`` and the key name will be the same as the |
Ezio Melotti | 5b69fbd | 2012-10-19 20:40:18 +0300 | [diff] [blame] | 570 | environment variables without the leading ``PY_`` prefix (and note that |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 571 | the key names in the INI file are case insensitive.) The contents of |
| 572 | an environment variable will override things specified in the INI file. |
| 573 | |
| 574 | For example: |
| 575 | |
| 576 | * Setting ``PY_PYTHON=3.1`` is equivalent to the INI file containing: |
| 577 | |
| 578 | :: |
| 579 | |
| 580 | [defaults] |
| 581 | python=3.1 |
| 582 | |
| 583 | * Setting ``PY_PYTHON=3`` and ``PY_PYTHON3=3.1`` is equivalent to the INI file |
| 584 | containing: |
| 585 | |
| 586 | :: |
| 587 | |
| 588 | [defaults] |
| 589 | python=3 |
| 590 | python3=3.1 |
| 591 | |
| 592 | Diagnostics |
| 593 | ----------- |
| 594 | |
| 595 | If an environment variable ``PYLAUNCH_DEBUG`` is set (to any value), the |
| 596 | launcher will print diagnostic information to stderr (i.e. to the console). |
| 597 | While this information manages to be simultaneously verbose *and* terse, it |
| 598 | should allow you to see what versions of Python were located, why a |
| 599 | particular version was chosen and the exact command-line used to execute the |
| 600 | target Python. |
| 601 | |
| 602 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 603 | |
| 604 | Finding modules |
| 605 | =============== |
| 606 | |
| 607 | Python usually stores its library (and thereby your site-packages folder) in the |
| 608 | installation directory. So, if you had installed Python to |
| 609 | :file:`C:\\Python\\`, the default library would reside in |
| 610 | :file:`C:\\Python\\Lib\\` and third-party modules should be stored in |
| 611 | :file:`C:\\Python\\Lib\\site-packages\\`. |
| 612 | |
| 613 | This is how :data:`sys.path` is populated on Windows: |
| 614 | |
| 615 | * An empty entry is added at the start, which corresponds to the current |
| 616 | directory. |
| 617 | |
| 618 | * If the environment variable :envvar:`PYTHONPATH` exists, as described in |
| 619 | :ref:`using-on-envvars`, its entries are added next. Note that on Windows, |
| 620 | paths in this variable must be separated by semicolons, to distinguish them |
| 621 | from the colon used in drive identifiers (``C:\`` etc.). |
| 622 | |
| 623 | * Additional "application paths" can be added in the registry as subkeys of |
| 624 | :samp:`\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath` under both the |
| 625 | ``HKEY_CURRENT_USER`` and ``HKEY_LOCAL_MACHINE`` hives. Subkeys which have |
| 626 | semicolon-delimited path strings as their default value will cause each path |
| 627 | to be added to :data:`sys.path`. (Note that all known installers only use |
| 628 | HKLM, so HKCU is typically empty.) |
| 629 | |
| 630 | * If the environment variable :envvar:`PYTHONHOME` is set, it is assumed as |
| 631 | "Python Home". Otherwise, the path of the main Python executable is used to |
| 632 | locate a "landmark file" (``Lib\os.py``) to deduce the "Python Home". If a |
| 633 | Python home is found, the relevant sub-directories added to :data:`sys.path` |
| 634 | (``Lib``, ``plat-win``, etc) are based on that folder. Otherwise, the core |
| 635 | Python path is constructed from the PythonPath stored in the registry. |
| 636 | |
| 637 | * If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified in |
| 638 | the environment, and no registry entries can be found, a default path with |
| 639 | relative entries is used (e.g. ``.\Lib;.\plat-win``, etc). |
| 640 | |
| 641 | The end result of all this is: |
| 642 | |
| 643 | * When running :file:`python.exe`, or any other .exe in the main Python |
| 644 | directory (either an installed version, or directly from the PCbuild |
| 645 | directory), the core path is deduced, and the core paths in the registry are |
| 646 | ignored. Other "application paths" in the registry are always read. |
| 647 | |
| 648 | * When Python is hosted in another .exe (different directory, embedded via COM, |
| 649 | etc), the "Python Home" will not be deduced, so the core path from the |
| 650 | registry is used. Other "application paths" in the registry are always read. |
| 651 | |
| 652 | * If Python can't find its home and there is no registry (eg, frozen .exe, some |
| 653 | very strange installation setup) you get a path with some default, but |
| 654 | relative, paths. |
| 655 | |
| 656 | For those who want to bundle Python into their application or distribution, the |
| 657 | following advice will prevent conflicts with other installations: |
| 658 | |
| 659 | * If you are loading :file:`python3.dll` or :file:`python35.dll` in your own |
| 660 | executable, explicitly call :c:func:`Py_SetPath` or (at least) |
| 661 | :c:func:`Py_SetProgramName` before :c:func:`Py_Initialize`. |
| 662 | |
| 663 | * Clear and/or overwrite :envvar:`PYTHONPATH` and set :envvar:`PYTHONHOME` |
| 664 | before launching :file:`python.exe` from your application. |
| 665 | |
| 666 | * If you cannot use the previous suggestions (for example, you are a |
| 667 | distribution that allows people to run :file:`python.exe` directly), ensure |
| 668 | that the landmark file (:file:`Lib\\os.py`) exists in your bundled library. |
| 669 | (Note that it will not be detected inside a ZIP file.) |
| 670 | |
| 671 | These will ensure that the files in a system-wide installation will not take |
| 672 | precedence over the copy of the standard library bundled with your application. |
| 673 | Otherwise, your users may experience problems using your application. |
| 674 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 675 | Additional modules |
| 676 | ================== |
| 677 | |
| 678 | Even though Python aims to be portable among all platforms, there are features |
| 679 | that are unique to Windows. A couple of modules, both in the standard library |
| 680 | and external, and snippets exist to use these features. |
| 681 | |
| 682 | The Windows-specific standard modules are documented in |
| 683 | :ref:`mswin-specific-services`. |
| 684 | |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 685 | PyWin32 |
| 686 | ------- |
| 687 | |
| 688 | The `PyWin32 <http://python.net/crew/mhammond/win32/>`_ module by Mark Hammond |
| 689 | is a collection of modules for advanced Windows-specific support. This includes |
Georg Brandl | 2ee470f | 2008-07-16 12:55:28 +0000 | [diff] [blame] | 690 | utilities for: |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 691 | |
| 692 | * `Component Object Model <http://www.microsoft.com/com/>`_ (COM) |
| 693 | * Win32 API calls |
| 694 | * Registry |
| 695 | * Event log |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 696 | * `Microsoft Foundation Classes <http://msdn.microsoft.com/en-us/library/fe1cf721%28VS.80%29.aspx>`_ (MFC) |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 697 | user interfaces |
| 698 | |
| 699 | `PythonWin <http://web.archive.org/web/20060524042422/ |
Georg Brandl | e73778c | 2014-10-29 08:36:35 +0100 | [diff] [blame] | 700 | https://www.python.org/windows/pythonwin/>`_ is a sample MFC application |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 701 | shipped with PyWin32. It is an embeddable IDE with a built-in debugger. |
| 702 | |
| 703 | .. seealso:: |
| 704 | |
| 705 | `Win32 How Do I...? <http://timgolden.me.uk/python/win32_how_do_i.html>`_ |
| 706 | by Tim Golden |
| 707 | |
| 708 | `Python and COM <http://www.boddie.org.uk/python/COM.html>`_ |
| 709 | by David and Paul Boddie |
| 710 | |
| 711 | |
Zachary Ware | c3cf97b | 2014-01-17 15:23:42 -0600 | [diff] [blame] | 712 | cx_Freeze |
| 713 | --------- |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 714 | |
Zachary Ware | c3cf97b | 2014-01-17 15:23:42 -0600 | [diff] [blame] | 715 | `cx_Freeze <http://cx-freeze.sourceforge.net/>`_ is a :mod:`distutils` |
| 716 | extension (see :ref:`extending-distutils`) which wraps Python scripts into |
| 717 | executable Windows programs (:file:`{*}.exe` files). When you have done this, |
| 718 | you can distribute your application without requiring your users to install |
| 719 | Python. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 720 | |
| 721 | |
| 722 | WConio |
| 723 | ------ |
| 724 | |
| 725 | Since Python's advanced terminal handling layer, :mod:`curses`, is restricted to |
| 726 | Unix-like systems, there is a library exclusive to Windows as well: Windows |
| 727 | Console I/O for Python. |
| 728 | |
| 729 | `WConio <http://newcenturycomputers.net/projects/wconio.html>`_ is a wrapper for |
| 730 | Turbo-C's :file:`CONIO.H`, used to create text user interfaces. |
| 731 | |
| 732 | |
| 733 | |
| 734 | Compiling Python on Windows |
| 735 | =========================== |
| 736 | |
| 737 | If you want to compile CPython yourself, first thing you should do is get the |
Georg Brandl | e73778c | 2014-10-29 08:36:35 +0100 | [diff] [blame] | 738 | `source <https://www.python.org/download/source/>`_. You can download either the |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 739 | latest release's source or just grab a fresh `checkout |
Georg Brandl | b7354a6 | 2014-10-29 10:57:37 +0100 | [diff] [blame] | 740 | <https://docs.python.org/devguide/setup.html#getting-the-source-code>`_. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 741 | |
Zachary Ware | f8ceb04 | 2013-11-30 16:59:33 -0600 | [diff] [blame] | 742 | The source tree contains a build solution and project files for Microsoft |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 743 | Visual Studio 2015, which is the compiler used to build the official Python |
| 744 | releases. These files are in the :file:`PCbuild` directory. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 745 | |
Zachary Ware | f8ceb04 | 2013-11-30 16:59:33 -0600 | [diff] [blame] | 746 | Check :file:`PCbuild/readme.txt` for general information on the build process. |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 747 | |
| 748 | |
| 749 | For extension modules, consult :ref:`building-on-windows`. |
| 750 | |
| 751 | .. seealso:: |
| 752 | |
| 753 | `Python + Windows + distutils + SWIG + gcc MinGW <http://sebsauvage.net/python/mingw.html>`_ |
| 754 | or "Creating Python extensions in C/C++ with SWIG and compiling them with |
| 755 | MinGW gcc under Windows" or "Installing Python extension with distutils |
| 756 | and without Microsoft Visual C++" by Sébastien Sauvage, 2003 |
| 757 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 758 | `MingW -- Python extensions <http://oldwiki.mingw.org/index.php/Python%20extensions>`_ |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 759 | by Trent Apted et al, 2007 |
| 760 | |
| 761 | |
| 762 | Other resources |
| 763 | =============== |
| 764 | |
| 765 | .. seealso:: |
| 766 | |
Georg Brandl | b7354a6 | 2014-10-29 10:57:37 +0100 | [diff] [blame] | 767 | `Python Programming On Win32 <http://shop.oreilly.com/product/9781565926219.do>`_ |
Christian Heimes | d8654cf | 2007-12-02 15:22:16 +0000 | [diff] [blame] | 768 | "Help for Windows Programmers" |
| 769 | by Mark Hammond and Andy Robinson, O'Reilly Media, 2000, |
| 770 | ISBN 1-56592-621-8 |
| 771 | |
| 772 | `A Python for Windows Tutorial <http://www.imladris.com/Scripts/PythonForWindows.html>`_ |
| 773 | by Amanda Birmingham, 2004 |
| 774 | |
Vinay Sajip | d89dae1 | 2012-06-24 11:23:07 +0100 | [diff] [blame] | 775 | :pep:`397` - Python launcher for Windows |
| 776 | The proposal for the launcher to be included in the Python distribution. |
| 777 | |
| 778 | |