1.. highlight:: none 2 3.. _using-on-windows: 4 5************************* 6 Using Python on Windows 7************************* 8 9.. sectionauthor:: Robert Lehmann <lehmannro@gmail.com> 10.. sectionauthor:: Steve Dower <steve.dower@microsoft.com> 11 12This document aims to give an overview of Windows-specific behaviour you should 13know about when using Python on Microsoft Windows. 14 15Unlike most Unix systems and services, Windows does not include a system 16supported installation of Python. To make Python available, the CPython team 17has compiled Windows installers (MSI packages) with every `release 18<https://www.python.org/download/releases/>`_ for many years. These installers 19are primarily intended to add a per-user installation of Python, with the 20core interpreter and library being used by a single user. The installer is also 21able to install for all users of a single machine, and a separate ZIP file is 22available for application-local distributions. 23 24As specified in :pep:`11`, a Python release only supports a Windows platform 25while Microsoft considers the platform under extended support. This means that 26Python |version| supports Windows 8.1 and newer. If you require Windows 7 27support, please install Python 3.8. 28 29There are a number of different installers available for Windows, each with 30certain benefits and downsides. 31 32:ref:`windows-full` contains all components and is the best option for 33developers using Python for any kind of project. 34 35:ref:`windows-store` is a simple installation of Python that is suitable for 36running scripts and packages, and using IDLE or other development environments. 37It requires Windows 10 and above, but can be safely installed without corrupting other 38programs. It also provides many convenient commands for launching Python and 39its tools. 40 41:ref:`windows-nuget` are lightweight installations intended for continuous 42integration systems. It can be used to build Python packages or run scripts, 43but is not updateable and has no user interface tools. 44 45:ref:`windows-embeddable` is a minimal package of Python suitable for 46embedding into a larger application. 47 48 49.. _windows-full: 50 51The full installer 52================== 53 54Installation steps 55------------------ 56 57Four Python |version| installers are available for download - two each for the 5832-bit and 64-bit versions of the interpreter. The *web installer* is a small 59initial download, and it will automatically download the required components as 60necessary. The *offline installer* includes the components necessary for a 61default installation and only requires an internet connection for optional 62features. See :ref:`install-layout-option` for other ways to avoid downloading 63during installation. 64 65After starting the installer, one of two options may be selected: 66 67.. image:: win_installer.png 68 69If you select "Install Now": 70 71* You will *not* need to be an administrator (unless a system update for the 72 C Runtime Library is required or you install the :ref:`launcher` for all 73 users) 74* Python will be installed into your user directory 75* The :ref:`launcher` will be installed according to the option at the bottom 76 of the first page 77* The standard library, test suite, launcher and pip will be installed 78* If selected, the install directory will be added to your :envvar:`PATH` 79* Shortcuts will only be visible for the current user 80 81Selecting "Customize installation" will allow you to select the features to 82install, the installation location and other options or post-install actions. 83To install debugging symbols or binaries, you will need to use this option. 84 85To perform an all-users installation, you should select "Customize 86installation". In this case: 87 88* You may be required to provide administrative credentials or approval 89* Python will be installed into the Program Files directory 90* The :ref:`launcher` will be installed into the Windows directory 91* Optional features may be selected during installation 92* The standard library can be pre-compiled to bytecode 93* If selected, the install directory will be added to the system :envvar:`PATH` 94* Shortcuts are available for all users 95 96.. _max-path: 97 98Removing the MAX_PATH Limitation 99-------------------------------- 100 101Windows historically has limited path lengths to 260 characters. This meant that 102paths longer than this would not resolve and errors would result. 103 104In the latest versions of Windows, this limitation can be expanded to 105approximately 32,000 characters. Your administrator will need to activate the 106"Enable Win32 long paths" group policy, or set ``LongPathsEnabled`` to ``1`` 107in the registry key 108``HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem``. 109 110This allows the :func:`open` function, the :mod:`os` module and most other 111path functionality to accept and return paths longer than 260 characters. 112 113After changing the above option, no further configuration is required. 114 115.. versionchanged:: 3.6 116 117 Support for long paths was enabled in Python. 118 119.. _install-quiet-option: 120 121Installing Without UI 122--------------------- 123 124All of the options available in the installer UI can also be specified from the 125command line, allowing scripted installers to replicate an installation on many 126machines without user interaction. These options may also be set without 127suppressing the UI in order to change some of the defaults. 128 129To completely hide the installer UI and install Python silently, pass the 130``/quiet`` option. To skip past the user interaction but still display 131progress and errors, pass the ``/passive`` option. The ``/uninstall`` 132option may be passed to immediately begin removing Python - no confirmation 133prompt will be displayed. 134 135All other options are passed as ``name=value``, where the value is usually 136``0`` to disable a feature, ``1`` to enable a feature, or a path. The full list 137of available options is shown below. 138 139+---------------------------+--------------------------------------+--------------------------+ 140| Name | Description | Default | 141+===========================+======================================+==========================+ 142| InstallAllUsers | Perform a system-wide installation. | 0 | 143+---------------------------+--------------------------------------+--------------------------+ 144| TargetDir | The installation directory | Selected based on | 145| | | InstallAllUsers | 146+---------------------------+--------------------------------------+--------------------------+ 147| DefaultAllUsersTargetDir | The default installation directory | :file:`%ProgramFiles%\\\ | 148| | for all-user installs | Python X.Y` or :file:`\ | 149| | | %ProgramFiles(x86)%\\\ | 150| | | Python X.Y` | 151+---------------------------+--------------------------------------+--------------------------+ 152| DefaultJustForMeTargetDir | The default install directory for | :file:`%LocalAppData%\\\ | 153| | just-for-me installs | Programs\\Python\\\ | 154| | | PythonXY` or | 155| | | :file:`%LocalAppData%\\\ | 156| | | Programs\\Python\\\ | 157| | | PythonXY-32` or | 158| | | :file:`%LocalAppData%\\\ | 159| | | Programs\\Python\\\ | 160| | | PythonXY-64` | 161+---------------------------+--------------------------------------+--------------------------+ 162| DefaultCustomTargetDir | The default custom install directory | (empty) | 163| | displayed in the UI | | 164+---------------------------+--------------------------------------+--------------------------+ 165| AssociateFiles | Create file associations if the | 1 | 166| | launcher is also installed. | | 167+---------------------------+--------------------------------------+--------------------------+ 168| CompileAll | Compile all ``.py`` files to | 0 | 169| | ``.pyc``. | | 170+---------------------------+--------------------------------------+--------------------------+ 171| PrependPath | Prepend install and Scripts | 0 | 172| | directories to :envvar:`PATH` and | | 173| | add ``.PY`` to :envvar:`PATHEXT` | | 174+---------------------------+--------------------------------------+--------------------------+ 175| AppendPath | Append install and Scripts | 0 | 176| | directories to :envvar:`PATH` and | | 177| | add ``.PY`` to :envvar:`PATHEXT` | | 178+---------------------------+--------------------------------------+--------------------------+ 179| Shortcuts | Create shortcuts for the interpreter,| 1 | 180| | documentation and IDLE if installed. | | 181+---------------------------+--------------------------------------+--------------------------+ 182| Include_doc | Install Python manual | 1 | 183+---------------------------+--------------------------------------+--------------------------+ 184| Include_debug | Install debug binaries | 0 | 185+---------------------------+--------------------------------------+--------------------------+ 186| Include_dev | Install developer headers and | 1 | 187| | libraries. Omitting this may lead to | | 188| | an unusable installation. | | 189+---------------------------+--------------------------------------+--------------------------+ 190| Include_exe | Install :file:`python.exe` and | 1 | 191| | related files. Omitting this may | | 192| | lead to an unusable installation. | | 193+---------------------------+--------------------------------------+--------------------------+ 194| Include_launcher | Install :ref:`launcher`. | 1 | 195+---------------------------+--------------------------------------+--------------------------+ 196| InstallLauncherAllUsers | Installs the launcher for all | 1 | 197| | users. Also requires | | 198| | ``Include_launcher`` to be set to 1 | | 199+---------------------------+--------------------------------------+--------------------------+ 200| Include_lib | Install standard library and | 1 | 201| | extension modules. Omitting this may | | 202| | lead to an unusable installation. | | 203+---------------------------+--------------------------------------+--------------------------+ 204| Include_pip | Install bundled pip and setuptools | 1 | 205+---------------------------+--------------------------------------+--------------------------+ 206| Include_symbols | Install debugging symbols (``*.pdb``)| 0 | 207+---------------------------+--------------------------------------+--------------------------+ 208| Include_tcltk | Install Tcl/Tk support and IDLE | 1 | 209+---------------------------+--------------------------------------+--------------------------+ 210| Include_test | Install standard library test suite | 1 | 211+---------------------------+--------------------------------------+--------------------------+ 212| Include_tools | Install utility scripts | 1 | 213+---------------------------+--------------------------------------+--------------------------+ 214| LauncherOnly | Only installs the launcher. This | 0 | 215| | will override most other options. | | 216+---------------------------+--------------------------------------+--------------------------+ 217| SimpleInstall | Disable most install UI | 0 | 218+---------------------------+--------------------------------------+--------------------------+ 219| SimpleInstallDescription | A custom message to display when the | (empty) | 220| | simplified install UI is used. | | 221+---------------------------+--------------------------------------+--------------------------+ 222 223For example, to silently install a default, system-wide Python installation, 224you could use the following command (from an elevated command prompt):: 225 226 python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 227 228To allow users to easily install a personal copy of Python without the test 229suite, you could provide a shortcut with the following command. This will 230display a simplified initial page and disallow customization:: 231 232 python-3.9.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0 233 SimpleInstall=1 SimpleInstallDescription="Just for me, no test suite." 234 235(Note that omitting the launcher also omits file associations, and is only 236recommended for per-user installs when there is also a system-wide installation 237that included the launcher.) 238 239The options listed above can also be provided in a file named ``unattend.xml`` 240alongside the executable. This file specifies a list of options and values. 241When a value is provided as an attribute, it will be converted to a number if 242possible. Values provided as element text are always left as strings. This 243example file sets the same options as the previous example: 244 245.. code-block:: xml 246 247 <Options> 248 <Option Name="InstallAllUsers" Value="no" /> 249 <Option Name="Include_launcher" Value="0" /> 250 <Option Name="Include_test" Value="no" /> 251 <Option Name="SimpleInstall" Value="yes" /> 252 <Option Name="SimpleInstallDescription">Just for me, no test suite</Option> 253 </Options> 254 255.. _install-layout-option: 256 257Installing Without Downloading 258------------------------------ 259 260As some features of Python are not included in the initial installer download, 261selecting those features may require an internet connection. To avoid this 262need, all possible components may be downloaded on-demand to create a complete 263*layout* that will no longer require an internet connection regardless of the 264selected features. Note that this download may be bigger than required, but 265where a large number of installations are going to be performed it is very 266useful to have a locally cached copy. 267 268Execute the following command from Command Prompt to download all possible 269required files. Remember to substitute ``python-3.9.0.exe`` for the actual 270name of your installer, and to create layouts in their own directories to 271avoid collisions between files with the same name. 272 273:: 274 275 python-3.9.0.exe /layout [optional target directory] 276 277You may also specify the ``/quiet`` option to hide the progress display. 278 279Modifying an install 280-------------------- 281 282Once Python has been installed, you can add or remove features through the 283Programs and Features tool that is part of Windows. Select the Python entry and 284choose "Uninstall/Change" to open the installer in maintenance mode. 285 286"Modify" allows you to add or remove features by modifying the checkboxes - 287unchanged checkboxes will not install or remove anything. Some options cannot be 288changed in this mode, such as the install directory; to modify these, you will 289need to remove and then reinstall Python completely. 290 291"Repair" will verify all the files that should be installed using the current 292settings and replace any that have been removed or modified. 293 294"Uninstall" will remove Python entirely, with the exception of the 295:ref:`launcher`, which has its own entry in Programs and Features. 296 297 298.. _windows-store: 299 300The Microsoft Store package 301=========================== 302 303.. versionadded:: 3.7.2 304 305The Microsoft Store package is an easily installable Python interpreter that 306is intended mainly for interactive use, for example, by students. 307 308To install the package, ensure you have the latest Windows 10 updates and 309search the Microsoft Store app for "Python |version|". Ensure that the app 310you select is published by the Python Software Foundation, and install it. 311 312.. warning:: 313 Python will always be available for free on the Microsoft Store. If you 314 are asked to pay for it, you have not selected the correct package. 315 316After installation, Python may be launched by finding it in Start. 317Alternatively, it will be available from any Command Prompt or PowerShell 318session by typing ``python``. Further, pip and IDLE may be used by typing 319``pip`` or ``idle``. IDLE can also be found in Start. 320 321All three commands are also available with version number suffixes, for 322example, as ``python3.exe`` and ``python3.x.exe`` as well as 323``python.exe`` (where ``3.x`` is the specific version you want to launch, 324such as |version|). Open "Manage App Execution Aliases" through Start to 325select which version of Python is associated with each command. It is 326recommended to make sure that ``pip`` and ``idle`` are consistent with 327whichever version of ``python`` is selected. 328 329Virtual environments can be created with ``python -m venv`` and activated 330and used as normal. 331 332If you have installed another version of Python and added it to your 333``PATH`` variable, it will be available as ``python.exe`` rather than the 334one from the Microsoft Store. To access the new installation, use 335``python3.exe`` or ``python3.x.exe``. 336 337The ``py.exe`` launcher will detect this Python installation, but will prefer 338installations from the traditional installer. 339 340To remove Python, open Settings and use Apps and Features, or else find 341Python in Start and right-click to select Uninstall. Uninstalling will 342remove all packages you installed directly into this Python installation, but 343will not remove any virtual environments 344 345Known issues 346------------ 347 348Redirection of local data, registry, and temporary paths 349^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 350 351Because of restrictions on Microsoft Store apps, Python scripts may not have 352full write access to shared locations such as :envvar:`TEMP` and the registry. 353Instead, it will write to a private copy. If your scripts must modify the 354shared locations, you will need to install the full installer. 355 356At runtime, Python will use a private copy of well-known Windows folders and the registry. 357For example, if the environment variable :envvar:`%APPDATA%` is :file:`c:\\Users\\<user>\\AppData\\`, 358then when writing to :file:`C:\\Users\\<user>\\AppData\\Local` will write to 359:file:`C:\\Users\\<user>\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\`. 360 361When reading files, Windows will return the file from the private folder, or if that does not exist, the 362real Windows directory. For example reading :file:`C:\\Windows\\System32` returns the contents of :file:`C:\\Windows\\System32` 363plus the contents of :file:`C:\\Program Files\\WindowsApps\\package_name\\VFS\\SystemX86`. 364 365You can find the real path of any existing file using :func:`os.path.realpath`: 366 367.. code-block:: python 368 369 >>> import os 370 >>> test_file = 'C:\\Users\\example\\AppData\\Local\\test.txt' 371 >>> os.path.realpath(test_file) 372 'C:\\Users\\example\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\test.txt' 373 374When writing to the Windows Registry, the following behaviors exist: 375 376* Reading from ``HKLM\\Software`` is allowed and results are merged with the :file:`registry.dat` file in the package. 377* Writing to ``HKLM\\Software`` is not allowed if the corresponding key/value exists, i.e. modifying existing keys. 378* Writing to ``HKLM\\Software`` is allowed as long as a corresponding key/value does not exist in the package 379 and the user has the correct access permissions. 380 381For more detail on the technical basis for these limitations, please consult 382Microsoft's documentation on packaged full-trust apps, currently available at 383`docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes 384<https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes>`_ 385 386 387.. _windows-nuget: 388 389The nuget.org packages 390====================== 391 392.. versionadded:: 3.5.2 393 394The nuget.org package is a reduced size Python environment intended for use on 395continuous integration and build systems that do not have a system-wide 396install of Python. While nuget is "the package manager for .NET", it also works 397perfectly fine for packages containing build-time tools. 398 399Visit `nuget.org <https://www.nuget.org/>`_ for the most up-to-date information 400on using nuget. What follows is a summary that is sufficient for Python 401developers. 402 403The ``nuget.exe`` command line tool may be downloaded directly from 404``https://aka.ms/nugetclidl``, for example, using curl or PowerShell. With the 405tool, the latest version of Python for 64-bit or 32-bit machines is installed 406using:: 407 408 nuget.exe install python -ExcludeVersion -OutputDirectory . 409 nuget.exe install pythonx86 -ExcludeVersion -OutputDirectory . 410 411To select a particular version, add a ``-Version 3.x.y``. The output directory 412may be changed from ``.``, and the package will be installed into a 413subdirectory. By default, the subdirectory is named the same as the package, 414and without the ``-ExcludeVersion`` option this name will include the specific 415version installed. Inside the subdirectory is a ``tools`` directory that 416contains the Python installation: 417 418.. code-block:: doscon 419 420 # Without -ExcludeVersion 421 > .\python.3.5.2\tools\python.exe -V 422 Python 3.5.2 423 424 # With -ExcludeVersion 425 > .\python\tools\python.exe -V 426 Python 3.5.2 427 428In general, nuget packages are not upgradeable, and newer versions should be 429installed side-by-side and referenced using the full path. Alternatively, 430delete the package directory manually and install it again. Many CI systems 431will do this automatically if they do not preserve files between builds. 432 433Alongside the ``tools`` directory is a ``build\native`` directory. This 434contains a MSBuild properties file ``python.props`` that can be used in a 435C++ project to reference the Python install. Including the settings will 436automatically use the headers and import libraries in your build. 437 438The package information pages on nuget.org are 439`www.nuget.org/packages/python <https://www.nuget.org/packages/python>`_ 440for the 64-bit version and `www.nuget.org/packages/pythonx86 441<https://www.nuget.org/packages/pythonx86>`_ for the 32-bit version. 442 443 444.. _windows-embeddable: 445 446The embeddable package 447====================== 448 449.. versionadded:: 3.5 450 451The embedded distribution is a ZIP file containing a minimal Python environment. 452It is intended for acting as part of another application, rather than being 453directly accessed by end-users. 454 455When extracted, the embedded distribution is (almost) fully isolated from the 456user's system, including environment variables, system registry settings, and 457installed packages. The standard library is included as pre-compiled and 458optimized ``.pyc`` files in a ZIP, and ``python3.dll``, ``python37.dll``, 459``python.exe`` and ``pythonw.exe`` are all provided. Tcl/tk (including all 460dependents, such as Idle), pip and the Python documentation are not included. 461 462.. note:: 463 464 The embedded distribution does not include the `Microsoft C Runtime 465 <https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist#visual-studio-2015-2017-2019-and-2022>`_ and it is 466 the responsibility of the application installer to provide this. The 467 runtime may have already been installed on a user's system previously or 468 automatically via Windows Update, and can be detected by finding 469 ``ucrtbase.dll`` in the system directory. 470 471Third-party packages should be installed by the application installer alongside 472the embedded distribution. Using pip to manage dependencies as for a regular 473Python installation is not supported with this distribution, though with some 474care it may be possible to include and use pip for automatic updates. In 475general, third-party packages should be treated as part of the application 476("vendoring") so that the developer can ensure compatibility with newer 477versions before providing updates to users. 478 479The two recommended use cases for this distribution are described below. 480 481Python Application 482------------------ 483 484An application written in Python does not necessarily require users to be aware 485of that fact. The embedded distribution may be used in this case to include a 486private version of Python in an install package. Depending on how transparent it 487should be (or conversely, how professional it should appear), there are two 488options. 489 490Using a specialized executable as a launcher requires some coding, but provides 491the most transparent experience for users. With a customized launcher, there are 492no obvious indications that the program is running on Python: icons can be 493customized, company and version information can be specified, and file 494associations behave properly. In most cases, a custom launcher should simply be 495able to call ``Py_Main`` with a hard-coded command line. 496 497The simpler approach is to provide a batch file or generated shortcut that 498directly calls the ``python.exe`` or ``pythonw.exe`` with the required 499command-line arguments. In this case, the application will appear to be Python 500and not its actual name, and users may have trouble distinguishing it from other 501running Python processes or file associations. 502 503With the latter approach, packages should be installed as directories alongside 504the Python executable to ensure they are available on the path. With the 505specialized launcher, packages can be located in other locations as there is an 506opportunity to specify the search path before launching the application. 507 508Embedding Python 509---------------- 510 511Applications written in native code often require some form of scripting 512language, and the embedded Python distribution can be used for this purpose. In 513general, the majority of the application is in native code, and some part will 514either invoke ``python.exe`` or directly use ``python3.dll``. For either case, 515extracting the embedded distribution to a subdirectory of the application 516installation is sufficient to provide a loadable Python interpreter. 517 518As with the application use, packages can be installed to any location as there 519is an opportunity to specify search paths before initializing the interpreter. 520Otherwise, there is no fundamental differences between using the embedded 521distribution and a regular installation. 522 523 524Alternative bundles 525=================== 526 527Besides the standard CPython distribution, there are modified packages including 528additional functionality. The following is a list of popular versions and their 529key features: 530 531`ActivePython <https://www.activestate.com/products/python/>`_ 532 Installer with multi-platform compatibility, documentation, PyWin32 533 534`Anaconda <https://www.anaconda.com/download/>`_ 535 Popular scientific modules (such as numpy, scipy and pandas) and the 536 ``conda`` package manager. 537 538`Enthought Deployment Manager <https://www.enthought.com/edm/>`_ 539 "The Next Generation Python Environment and Package Manager". 540 541 Previously Enthought provided Canopy, but it `reached end of life in 2016 542 <https://support.enthought.com/hc/en-us/articles/360038600051-Canopy-GUI-end-of-life-transition-to-the-Enthought-Deployment-Manager-EDM-and-Visual-Studio-Code>`_. 543 544`WinPython <https://winpython.github.io/>`_ 545 Windows-specific distribution with prebuilt scientific packages and 546 tools for building packages. 547 548Note that these packages may not include the latest versions of Python or 549other libraries, and are not maintained or supported by the core Python team. 550 551 552 553Configuring Python 554================== 555 556To run Python conveniently from a command prompt, you might consider changing 557some default environment variables in Windows. While the installer provides an 558option to configure the PATH and PATHEXT variables for you, this is only 559reliable for a single, system-wide installation. If you regularly use multiple 560versions of Python, consider using the :ref:`launcher`. 561 562 563.. _setting-envvars: 564 565Excursus: Setting environment variables 566--------------------------------------- 567 568Windows allows environment variables to be configured permanently at both the 569User level and the System level, or temporarily in a command prompt. 570 571To temporarily set environment variables, open Command Prompt and use the 572:command:`set` command: 573 574.. code-block:: doscon 575 576 C:\>set PATH=C:\Program Files\Python 3.9;%PATH% 577 C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib 578 C:\>python 579 580These changes will apply to any further commands executed in that console, and 581will be inherited by any applications started from the console. 582 583Including the variable name within percent signs will expand to the existing 584value, allowing you to add your new value at either the start or the end. 585Modifying :envvar:`PATH` by adding the directory containing 586:program:`python.exe` to the start is a common way to ensure the correct version 587of Python is launched. 588 589To permanently modify the default environment variables, click Start and search 590for 'edit environment variables', or open System properties, :guilabel:`Advanced 591system settings` and click the :guilabel:`Environment Variables` button. 592In this dialog, you can add or modify User and System variables. To change 593System variables, you need non-restricted access to your machine 594(i.e. Administrator rights). 595 596.. note:: 597 598 Windows will concatenate User variables *after* System variables, which may 599 cause unexpected results when modifying :envvar:`PATH`. 600 601 The :envvar:`PYTHONPATH` variable is used by all versions of Python, 602 so you should not permanently configure it unless the listed paths 603 only include code that is compatible with all of your installed Python 604 versions. 605 606.. seealso:: 607 608 https://docs.microsoft.com/en-us/windows/win32/procthread/environment-variables 609 Overview of environment variables on Windows 610 611 https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1 612 The ``set`` command, for temporarily modifying environment variables 613 614 https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx 615 The ``setx`` command, for permanently modifying environment variables 616 617 618.. _windows-path-mod: 619 620Finding the Python executable 621----------------------------- 622 623.. versionchanged:: 3.5 624 625Besides using the automatically created start menu entry for the Python 626interpreter, you might want to start Python in the command prompt. The 627installer has an option to set that up for you. 628 629On the first page of the installer, an option labelled "Add Python to PATH" 630may be selected to have the installer add the install location into the 631:envvar:`PATH`. The location of the :file:`Scripts\\` folder is also added. 632This allows you to type :command:`python` to run the interpreter, and 633:command:`pip` for the package installer. Thus, you can also execute your 634scripts with command line options, see :ref:`using-on-cmdline` documentation. 635 636If you don't enable this option at install time, you can always re-run the 637installer, select Modify, and enable it. Alternatively, you can manually 638modify the :envvar:`PATH` using the directions in :ref:`setting-envvars`. You 639need to set your :envvar:`PATH` environment variable to include the directory 640of your Python installation, delimited by a semicolon from other entries. An 641example variable could look like this (assuming the first two entries already 642existed):: 643 644 C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.9 645 646.. _win-utf8-mode: 647 648UTF-8 mode 649========== 650 651.. versionadded:: 3.7 652 653Windows still uses legacy encodings for the system encoding (the ANSI Code 654Page). Python uses it for the default encoding of text files (e.g. 655:func:`locale.getencoding`). 656 657This may cause issues because UTF-8 is widely used on the internet 658and most Unix systems, including WSL (Windows Subsystem for Linux). 659 660You can use the :ref:`Python UTF-8 Mode <utf8-mode>` to change the default text 661encoding to UTF-8. You can enable the :ref:`Python UTF-8 Mode <utf8-mode>` via 662the ``-X utf8`` command line option, or the ``PYTHONUTF8=1`` environment 663variable. See :envvar:`PYTHONUTF8` for enabling UTF-8 mode, and 664:ref:`setting-envvars` for how to modify environment variables. 665 666When the :ref:`Python UTF-8 Mode <utf8-mode>` is enabled, you can still use the 667system encoding (the ANSI Code Page) via the "mbcs" codec. 668 669Note that adding ``PYTHONUTF8=1`` to the default environment variables 670will affect all Python 3.7+ applications on your system. 671If you have any Python 3.7+ applications which rely on the legacy 672system encoding, it is recommended to set the environment variable 673temporarily or use the ``-X utf8`` command line option. 674 675.. note:: 676 Even when UTF-8 mode is disabled, Python uses UTF-8 by default 677 on Windows for: 678 679 * Console I/O including standard I/O (see :pep:`528` for details). 680 * The :term:`filesystem encoding <filesystem encoding and error handler>` 681 (see :pep:`529` for details). 682 683 684.. _launcher: 685 686Python Launcher for Windows 687=========================== 688 689.. versionadded:: 3.3 690 691The Python launcher for Windows is a utility which aids in locating and 692executing of different Python versions. It allows scripts (or the 693command-line) to indicate a preference for a specific Python version, and 694will locate and execute that version. 695 696Unlike the :envvar:`PATH` variable, the launcher will correctly select the most 697appropriate version of Python. It will prefer per-user installations over 698system-wide ones, and orders by language version rather than using the most 699recently installed version. 700 701The launcher was originally specified in :pep:`397`. 702 703Getting started 704--------------- 705 706From the command-line 707^^^^^^^^^^^^^^^^^^^^^ 708 709.. versionchanged:: 3.6 710 711System-wide installations of Python 3.3 and later will put the launcher on your 712:envvar:`PATH`. The launcher is compatible with all available versions of 713Python, so it does not matter which version is installed. To check that the 714launcher is available, execute the following command in Command Prompt:: 715 716 py 717 718You should find that the latest version of Python you have installed is 719started - it can be exited as normal, and any additional command-line 720arguments specified will be sent directly to Python. 721 722If you have multiple versions of Python installed (e.g., 3.7 and |version|) you 723will have noticed that Python |version| was started - to launch Python 3.7, try 724the command:: 725 726 py -3.7 727 728If you want the latest version of Python 2 you have installed, try the 729command:: 730 731 py -2 732 733If you see the following error, you do not have the launcher installed:: 734 735 'py' is not recognized as an internal or external command, 736 operable program or batch file. 737 738The command:: 739 740 py --list 741 742displays the currently installed version(s) of Python. 743 744The ``-x.y`` argument is the short form of the ``-V:Company/Tag`` argument, 745which allows selecting a specific Python runtime, including those that may have 746come from somewhere other than python.org. Any runtime registered by following 747:pep:`514` will be discoverable. The ``--list`` command lists all available 748runtimes using the ``-V:`` format. 749 750When using the ``-V:`` argument, specifying the Company will limit selection to 751runtimes from that provider, while specifying only the Tag will select from all 752providers. Note that omitting the slash implies a tag:: 753 754 # Select any '3.*' tagged runtime 755 py -V:3 756 757 # Select any 'PythonCore' released runtime 758 py -V:PythonCore/ 759 760 # Select PythonCore's latest Python 3 runtime 761 py -V:PythonCore/3 762 763The short form of the argument (``-3``) only ever selects from core Python 764releases, and not other distributions. However, the longer form (``-V:3``) will 765select from any. 766 767The Company is matched on the full string, case-insenitive. The Tag is matched 768oneither the full string, or a prefix, provided the next character is a dot or a 769hyphen. This allows ``-V:3.1`` to match ``3.1-32``, but not ``3.10``. Tags are 770sorted using numerical ordering (``3.10`` is newer than ``3.1``), but are 771compared using text (``-V:3.01`` does not match ``3.1``). 772 773 774Virtual environments 775^^^^^^^^^^^^^^^^^^^^ 776 777.. versionadded:: 3.5 778 779If the launcher is run with no explicit Python version specification, and a 780virtual environment (created with the standard library :mod:`venv` module or 781the external ``virtualenv`` tool) active, the launcher will run the virtual 782environment's interpreter rather than the global one. To run the global 783interpreter, either deactivate the virtual environment, or explicitly specify 784the global Python version. 785 786From a script 787^^^^^^^^^^^^^ 788 789Let's create a test Python script - create a file called ``hello.py`` with the 790following contents 791 792.. code-block:: python 793 794 #! python 795 import sys 796 sys.stdout.write("hello from Python %s\n" % (sys.version,)) 797 798From the directory in which hello.py lives, execute the command:: 799 800 py hello.py 801 802You should notice the version number of your latest Python 2.x installation 803is printed. Now try changing the first line to be: 804 805.. code-block:: python 806 807 #! python3 808 809Re-executing the command should now print the latest Python 3.x information. 810As with the above command-line examples, you can specify a more explicit 811version qualifier. Assuming you have Python 3.7 installed, try changing 812the first line to ``#! python3.7`` and you should find the 3.7 813version information printed. 814 815Note that unlike interactive use, a bare "python" will use the latest 816version of Python 2.x that you have installed. This is for backward 817compatibility and for compatibility with Unix, where the command ``python`` 818typically refers to Python 2. 819 820From file associations 821^^^^^^^^^^^^^^^^^^^^^^ 822 823The launcher should have been associated with Python files (i.e. ``.py``, 824``.pyw``, ``.pyc`` files) when it was installed. This means that 825when you double-click on one of these files from Windows explorer the launcher 826will be used, and therefore you can use the same facilities described above to 827have the script specify the version which should be used. 828 829The key benefit of this is that a single launcher can support multiple Python 830versions at the same time depending on the contents of the first line. 831 832Shebang Lines 833------------- 834 835If the first line of a script file starts with ``#!``, it is known as a 836"shebang" line. Linux and other Unix like operating systems have native 837support for such lines and they are commonly used on such systems to indicate 838how a script should be executed. This launcher allows the same facilities to 839be used with Python scripts on Windows and the examples above demonstrate their 840use. 841 842To allow shebang lines in Python scripts to be portable between Unix and 843Windows, this launcher supports a number of 'virtual' commands to specify 844which interpreter to use. The supported virtual commands are: 845 846* ``/usr/bin/env`` 847* ``/usr/bin/python`` 848* ``/usr/local/bin/python`` 849* ``python`` 850 851For example, if the first line of your script starts with 852 853.. code-block:: sh 854 855 #! /usr/bin/python 856 857The default Python will be located and used. As many Python scripts written 858to work on Unix will already have this line, you should find these scripts can 859be used by the launcher without modification. If you are writing a new script 860on Windows which you hope will be useful on Unix, you should use one of the 861shebang lines starting with ``/usr``. 862 863Any of the above virtual commands can be suffixed with an explicit version 864(either just the major version, or the major and minor version). 865Furthermore the 32-bit version can be requested by adding "-32" after the 866minor version. I.e. ``/usr/bin/python3.7-32`` will request usage of the 86732-bit python 3.7. 868 869.. versionadded:: 3.7 870 871 Beginning with python launcher 3.7 it is possible to request 64-bit version 872 by the "-64" suffix. Furthermore it is possible to specify a major and 873 architecture without minor (i.e. ``/usr/bin/python3-64``). 874 875.. versionchanged:: 3.11 876 877 The "-64" suffix is deprecated, and now implies "any architecture that is 878 not provably i386/32-bit". To request a specific environment, use the new 879 ``-V:<TAG>`` argument with the complete tag. 880 881The ``/usr/bin/env`` form of shebang line has one further special property. 882Before looking for installed Python interpreters, this form will search the 883executable :envvar:`PATH` for a Python executable matching the name provided 884as the first argument. This corresponds to the behaviour of the Unix ``env`` 885program, which performs a :envvar:`PATH` search. 886If an executable matching the first argument after the ``env`` command cannot 887be found, but the argument starts with ``python``, it will be handled as 888described for the other virtual commands. 889The environment variable :envvar:`PYLAUNCHER_NO_SEARCH_PATH` may be set 890(to any value) to skip this search of :envvar:`PATH`. 891 892Shebang lines that do not match any of these patterns are looked up in the 893``[commands]`` section of the launcher's :ref:`.INI file <launcher-ini>`. 894This may be used to handle certain commands in a way that makes sense for your 895system. The name of the command must be a single argument (no spaces in the 896shebang executable), and the value substituted is the full path to the 897executable (additional arguments specified in the .INI will be quoted as part 898of the filename). 899 900.. code-block:: ini 901 902 [commands] 903 /bin/xpython=C:\Program Files\XPython\python.exe 904 905Any commands not found in the .INI file are treated as **Windows** executable 906paths that are absolute or relative to the directory containing the script file. 907This is a convenience for Windows-only scripts, such as those generated by an 908installer, since the behavior is not compatible with Unix-style shells. 909These paths may be quoted, and may include multiple arguments, after which the 910path to the script and any additional arguments will be appended. 911 912 913Arguments in shebang lines 914-------------------------- 915 916The shebang lines can also specify additional options to be passed to the 917Python interpreter. For example, if you have a shebang line: 918 919.. code-block:: sh 920 921 #! /usr/bin/python -v 922 923Then Python will be started with the ``-v`` option 924 925Customization 926------------- 927 928.. _launcher-ini: 929 930Customization via INI files 931^^^^^^^^^^^^^^^^^^^^^^^^^^^ 932 933Two .ini files will be searched by the launcher - ``py.ini`` in the current 934user's application data directory (``%LOCALAPPDATA%`` or ``$env:LocalAppData``) 935and ``py.ini`` in the same directory as the launcher. The same .ini files are 936used for both the 'console' version of the launcher (i.e. py.exe) and for the 937'windows' version (i.e. pyw.exe). 938 939Customization specified in the "application directory" will have precedence over 940the one next to the executable, so a user, who may not have write access to the 941.ini file next to the launcher, can override commands in that global .ini file. 942 943Customizing default Python versions 944^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 945 946In some cases, a version qualifier can be included in a command to dictate 947which version of Python will be used by the command. A version qualifier 948starts with a major version number and can optionally be followed by a period 949('.') and a minor version specifier. Furthermore it is possible to specify 950if a 32 or 64 bit implementation shall be requested by adding "-32" or "-64". 951 952For example, a shebang line of ``#!python`` has no version qualifier, while 953``#!python3`` has a version qualifier which specifies only a major version. 954 955If no version qualifiers are found in a command, the environment 956variable :envvar:`PY_PYTHON` can be set to specify the default version 957qualifier. If it is not set, the default is "3". The variable can 958specify any value that may be passed on the command line, such as "3", 959"3.7", "3.7-32" or "3.7-64". (Note that the "-64" option is only 960available with the launcher included with Python 3.7 or newer.) 961 962If no minor version qualifiers are found, the environment variable 963``PY_PYTHON{major}`` (where ``{major}`` is the current major version qualifier 964as determined above) can be set to specify the full version. If no such option 965is found, the launcher will enumerate the installed Python versions and use 966the latest minor release found for the major version, which is likely, 967although not guaranteed, to be the most recently installed version in that 968family. 969 970On 64-bit Windows with both 32-bit and 64-bit implementations of the same 971(major.minor) Python version installed, the 64-bit version will always be 972preferred. This will be true for both 32-bit and 64-bit implementations of the 973launcher - a 32-bit launcher will prefer to execute a 64-bit Python installation 974of the specified version if available. This is so the behavior of the launcher 975can be predicted knowing only what versions are installed on the PC and 976without regard to the order in which they were installed (i.e., without knowing 977whether a 32 or 64-bit version of Python and corresponding launcher was 978installed last). As noted above, an optional "-32" or "-64" suffix can be 979used on a version specifier to change this behaviour. 980 981Examples: 982 983* If no relevant options are set, the commands ``python`` and 984 ``python2`` will use the latest Python 2.x version installed and 985 the command ``python3`` will use the latest Python 3.x installed. 986 987* The command ``python3.7`` will not consult any 988 options at all as the versions are fully specified. 989 990* If ``PY_PYTHON=3``, the commands ``python`` and ``python3`` will both use 991 the latest installed Python 3 version. 992 993* If ``PY_PYTHON=3.7-32``, the command ``python`` will use the 32-bit 994 implementation of 3.7 whereas the command ``python3`` will use the latest 995 installed Python (PY_PYTHON was not considered at all as a major 996 version was specified.) 997 998* If ``PY_PYTHON=3`` and ``PY_PYTHON3=3.7``, the commands 999 ``python`` and ``python3`` will both use specifically 3.7 1000 1001In addition to environment variables, the same settings can be configured 1002in the .INI file used by the launcher. The section in the INI file is 1003called ``[defaults]`` and the key name will be the same as the 1004environment variables without the leading ``PY_`` prefix (and note that 1005the key names in the INI file are case insensitive.) The contents of 1006an environment variable will override things specified in the INI file. 1007 1008For example: 1009 1010* Setting ``PY_PYTHON=3.7`` is equivalent to the INI file containing: 1011 1012.. code-block:: ini 1013 1014 [defaults] 1015 python=3.7 1016 1017* Setting ``PY_PYTHON=3`` and ``PY_PYTHON3=3.7`` is equivalent to the INI file 1018 containing: 1019 1020.. code-block:: ini 1021 1022 [defaults] 1023 python=3 1024 python3=3.7 1025 1026Diagnostics 1027----------- 1028 1029If an environment variable :envvar:`PYLAUNCHER_DEBUG` is set (to any value), the 1030launcher will print diagnostic information to stderr (i.e. to the console). 1031While this information manages to be simultaneously verbose *and* terse, it 1032should allow you to see what versions of Python were located, why a 1033particular version was chosen and the exact command-line used to execute the 1034target Python. It is primarily intended for testing and debugging. 1035 1036Dry Run 1037------- 1038 1039If an environment variable :envvar:`PYLAUNCHER_DRYRUN` is set (to any value), 1040the launcher will output the command it would have run, but will not actually 1041launch Python. This may be useful for tools that want to use the launcher to 1042detect and then launch Python directly. Note that the command written to 1043standard output is always encoded using UTF-8, and may not render correctly in 1044the console. 1045 1046Install on demand 1047----------------- 1048 1049If an environment variable :envvar:`PYLAUNCHER_ALLOW_INSTALL` is set (to any 1050value), and the requested Python version is not installed but is available on 1051the Microsoft Store, the launcher will attempt to install it. This may require 1052user interaction to complete, and you may need to run the command again. 1053 1054An additional :envvar:`PYLAUNCHER_ALWAYS_INSTALL` variable causes the launcher 1055to always try to install Python, even if it is detected. This is mainly intended 1056for testing (and should be used with :envvar:`PYLAUNCHER_DRYRUN`). 1057 1058Return codes 1059------------ 1060 1061The following exit codes may be returned by the Python launcher. Unfortunately, 1062there is no way to distinguish these from the exit code of Python itself. 1063 1064The names of codes are as used in the sources, and are only for reference. There 1065is no way to access or resolve them apart from reading this page. Entries are 1066listed in alphabetical order of names. 1067 1068+-------------------+-------+-----------------------------------------------+ 1069| Name | Value | Description | 1070+===================+=======+===============================================+ 1071| RC_BAD_VENV_CFG | 107 | A :file:`pyvenv.cfg` was found but is corrupt.| 1072+-------------------+-------+-----------------------------------------------+ 1073| RC_CREATE_PROCESS | 101 | Failed to launch Python. | 1074+-------------------+-------+-----------------------------------------------+ 1075| RC_INSTALLING | 111 | An install was started, but the command will | 1076| | | need to be re-run after it completes. | 1077+-------------------+-------+-----------------------------------------------+ 1078| RC_INTERNAL_ERROR | 109 | Unexpected error. Please report a bug. | 1079+-------------------+-------+-----------------------------------------------+ 1080| RC_NO_COMMANDLINE | 108 | Unable to obtain command line from the | 1081| | | operating system. | 1082+-------------------+-------+-----------------------------------------------+ 1083| RC_NO_PYTHON | 103 | Unable to locate the requested version. | 1084+-------------------+-------+-----------------------------------------------+ 1085| RC_NO_VENV_CFG | 106 | A :file:`pyvenv.cfg` was required but not | 1086| | | found. | 1087+-------------------+-------+-----------------------------------------------+ 1088 1089 1090.. _windows_finding_modules: 1091 1092Finding modules 1093=============== 1094 1095These notes supplement the description at :ref:`sys-path-init` with 1096detailed Windows notes. 1097 1098When no ``._pth`` file is found, this is how :data:`sys.path` is populated on 1099Windows: 1100 1101* An empty entry is added at the start, which corresponds to the current 1102 directory. 1103 1104* If the environment variable :envvar:`PYTHONPATH` exists, as described in 1105 :ref:`using-on-envvars`, its entries are added next. Note that on Windows, 1106 paths in this variable must be separated by semicolons, to distinguish them 1107 from the colon used in drive identifiers (``C:\`` etc.). 1108 1109* Additional "application paths" can be added in the registry as subkeys of 1110 :samp:`\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath` under both the 1111 ``HKEY_CURRENT_USER`` and ``HKEY_LOCAL_MACHINE`` hives. Subkeys which have 1112 semicolon-delimited path strings as their default value will cause each path 1113 to be added to :data:`sys.path`. (Note that all known installers only use 1114 HKLM, so HKCU is typically empty.) 1115 1116* If the environment variable :envvar:`PYTHONHOME` is set, it is assumed as 1117 "Python Home". Otherwise, the path of the main Python executable is used to 1118 locate a "landmark file" (either ``Lib\os.py`` or ``pythonXY.zip``) to deduce 1119 the "Python Home". If a Python home is found, the relevant sub-directories 1120 added to :data:`sys.path` (``Lib``, ``plat-win``, etc) are based on that 1121 folder. Otherwise, the core Python path is constructed from the PythonPath 1122 stored in the registry. 1123 1124* If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified in 1125 the environment, and no registry entries can be found, a default path with 1126 relative entries is used (e.g. ``.\Lib;.\plat-win``, etc). 1127 1128If a ``pyvenv.cfg`` file is found alongside the main executable or in the 1129directory one level above the executable, the following variations apply: 1130 1131* If ``home`` is an absolute path and :envvar:`PYTHONHOME` is not set, this 1132 path is used instead of the path to the main executable when deducing the 1133 home location. 1134 1135The end result of all this is: 1136 1137* When running :file:`python.exe`, or any other .exe in the main Python 1138 directory (either an installed version, or directly from the PCbuild 1139 directory), the core path is deduced, and the core paths in the registry are 1140 ignored. Other "application paths" in the registry are always read. 1141 1142* When Python is hosted in another .exe (different directory, embedded via COM, 1143 etc), the "Python Home" will not be deduced, so the core path from the 1144 registry is used. Other "application paths" in the registry are always read. 1145 1146* If Python can't find its home and there are no registry value (frozen .exe, 1147 some very strange installation setup) you get a path with some default, but 1148 relative, paths. 1149 1150For those who want to bundle Python into their application or distribution, the 1151following advice will prevent conflicts with other installations: 1152 1153* Include a ``._pth`` file alongside your executable containing the 1154 directories to include. This will ignore paths listed in the registry and 1155 environment variables, and also ignore :mod:`site` unless ``import site`` is 1156 listed. 1157 1158* If you are loading :file:`python3.dll` or :file:`python37.dll` in your own 1159 executable, explicitly call :c:func:`Py_SetPath` or (at least) 1160 :c:func:`Py_SetProgramName` before :c:func:`Py_Initialize`. 1161 1162* Clear and/or overwrite :envvar:`PYTHONPATH` and set :envvar:`PYTHONHOME` 1163 before launching :file:`python.exe` from your application. 1164 1165* If you cannot use the previous suggestions (for example, you are a 1166 distribution that allows people to run :file:`python.exe` directly), ensure 1167 that the landmark file (:file:`Lib\\os.py`) exists in your install directory. 1168 (Note that it will not be detected inside a ZIP file, but a correctly named 1169 ZIP file will be detected instead.) 1170 1171These will ensure that the files in a system-wide installation will not take 1172precedence over the copy of the standard library bundled with your application. 1173Otherwise, your users may experience problems using your application. Note that 1174the first suggestion is the best, as the others may still be susceptible to 1175non-standard paths in the registry and user site-packages. 1176 1177.. versionchanged:: 1178 3.6 1179 1180 * Adds ``._pth`` file support and removes ``applocal`` option from 1181 ``pyvenv.cfg``. 1182 * Adds ``pythonXX.zip`` as a potential landmark when directly adjacent 1183 to the executable. 1184 1185.. deprecated:: 1186 3.6 1187 1188 Modules specified in the registry under ``Modules`` (not ``PythonPath``) 1189 may be imported by :class:`importlib.machinery.WindowsRegistryFinder`. 1190 This finder is enabled on Windows in 3.6.0 and earlier, but may need to 1191 be explicitly added to :attr:`sys.meta_path` in the future. 1192 1193Additional modules 1194================== 1195 1196Even though Python aims to be portable among all platforms, there are features 1197that are unique to Windows. A couple of modules, both in the standard library 1198and external, and snippets exist to use these features. 1199 1200The Windows-specific standard modules are documented in 1201:ref:`mswin-specific-services`. 1202 1203PyWin32 1204------- 1205 1206The `PyWin32 <https://pypi.org/project/pywin32>`_ module by Mark Hammond 1207is a collection of modules for advanced Windows-specific support. This includes 1208utilities for: 1209 1210* `Component Object Model 1211 <https://docs.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal>`_ 1212 (COM) 1213* Win32 API calls 1214* Registry 1215* Event log 1216* `Microsoft Foundation Classes 1217 <https://docs.microsoft.com/en-us/cpp/mfc/mfc-desktop-applications>`_ 1218 (MFC) user interfaces 1219 1220`PythonWin <https://web.archive.org/web/20060524042422/ 1221https://www.python.org/windows/pythonwin/>`_ is a sample MFC application 1222shipped with PyWin32. It is an embeddable IDE with a built-in debugger. 1223 1224.. seealso:: 1225 1226 `Win32 How Do I...? <http://timgolden.me.uk/python/win32_how_do_i.html>`_ 1227 by Tim Golden 1228 1229 `Python and COM <https://www.boddie.org.uk/python/COM.html>`_ 1230 by David and Paul Boddie 1231 1232 1233cx_Freeze 1234--------- 1235 1236`cx_Freeze <https://cx-freeze.readthedocs.io/en/latest/>`_ is a :mod:`distutils` 1237extension (see :ref:`extending-distutils`) which wraps Python scripts into 1238executable Windows programs (:file:`{*}.exe` files). When you have done this, 1239you can distribute your application without requiring your users to install 1240Python. 1241 1242 1243Compiling Python on Windows 1244=========================== 1245 1246If you want to compile CPython yourself, first thing you should do is get the 1247`source <https://www.python.org/downloads/source/>`_. You can download either the 1248latest release's source or just grab a fresh `checkout 1249<https://devguide.python.org/setup/#get-the-source-code>`_. 1250 1251The source tree contains a build solution and project files for Microsoft 1252Visual Studio, which is the compiler used to build the official Python 1253releases. These files are in the :file:`PCbuild` directory. 1254 1255Check :file:`PCbuild/readme.txt` for general information on the build process. 1256 1257For extension modules, consult :ref:`building-on-windows`. 1258 1259 1260Other Platforms 1261=============== 1262 1263With ongoing development of Python, some platforms that used to be supported 1264earlier are no longer supported (due to the lack of users or developers). 1265Check :pep:`11` for details on all unsupported platforms. 1266 1267* `Windows CE <https://pythonce.sourceforge.net/>`_ is 1268 `no longer supported <https://github.com/python/cpython/issues/71542>`__ 1269 since Python 3 (if it ever was). 1270* The `Cygwin <https://cygwin.com/>`_ installer offers to install the 1271 `Python interpreter <https://cygwin.com/packages/summary/python3.html>`__ 1272 as well 1273 1274See `Python for Windows <https://www.python.org/downloads/windows/>`_ 1275for detailed information about platforms with pre-compiled installers. 1276