Lines Matching +full:shebang +full:- +full:command
3 .. _using-on-windows:
12 This document aims to give an overview of Windows-specific behaviour you should
19 are primarily intended to add a per-user installation of Python, with the
22 available for application-local distributions.
32 :ref:`windows-full` contains all components and is the best option for
35 :ref:`windows-store` is a simple installation of Python that is suitable for
41 :ref:`windows-nuget` are lightweight installations intended for continuous
45 :ref:`windows-embeddable` is a minimal package of Python suitable for
49 .. _windows-full:
55 ------------------
57 Four Python |version| installers are available for download - two each for the
58 32-bit and 64-bit versions of the interpreter. The *web installer* is a small
62 features. See :ref:`install-layout-option` for other ways to avoid downloading
82 install, the installation location and other options or post-install actions.
85 To perform an all-users installation, you should select "Customize
92 * The standard library can be pre-compiled to bytecode
96 .. _max-path:
99 --------------------------------
119 .. _install-quiet-option:
122 ---------------------
125 command line, allowing scripted installers to replicate an installation on many
132 option may be passed to immediately begin removing Python - no confirmation
139 +---------------------------+--------------------------------------+--------------------------+
142 | InstallAllUsers | Perform a system-wide installation. | 0 |
143 +---------------------------+--------------------------------------+--------------------------+
146 +---------------------------+--------------------------------------+--------------------------+
148 | | for all-user installs | Python X.Y` or :file:`\ |
151 +---------------------------+--------------------------------------+--------------------------+
153 | | just-for-me installs | Programs\\Python\\\ |
157 | | | PythonXY-32` or |
160 | | | PythonXY-64` |
161 +---------------------------+--------------------------------------+--------------------------+
164 +---------------------------+--------------------------------------+--------------------------+
167 +---------------------------+--------------------------------------+--------------------------+
170 +---------------------------+--------------------------------------+--------------------------+
174 +---------------------------+--------------------------------------+--------------------------+
178 +---------------------------+--------------------------------------+--------------------------+
181 +---------------------------+--------------------------------------+--------------------------+
183 +---------------------------+--------------------------------------+--------------------------+
185 +---------------------------+--------------------------------------+--------------------------+
189 +---------------------------+--------------------------------------+--------------------------+
193 +---------------------------+--------------------------------------+--------------------------+
195 +---------------------------+--------------------------------------+--------------------------+
199 +---------------------------+--------------------------------------+--------------------------+
203 +---------------------------+--------------------------------------+--------------------------+
205 +---------------------------+--------------------------------------+--------------------------+
207 +---------------------------+--------------------------------------+--------------------------+
209 +---------------------------+--------------------------------------+--------------------------+
211 +---------------------------+--------------------------------------+--------------------------+
213 +---------------------------+--------------------------------------+--------------------------+
216 +---------------------------+--------------------------------------+--------------------------+
218 +---------------------------+--------------------------------------+--------------------------+
221 +---------------------------+--------------------------------------+--------------------------+
223 For example, to silently install a default, system-wide Python installation,
224 you could use the following command (from an elevated command prompt)::
226 python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
229 suite, you could provide a shortcut with the following command. This will
232 python-3.9.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0
236 recommended for per-user installs when there is also a system-wide installation
245 .. code-block:: xml
255 .. _install-layout-option:
258 ------------------------------
262 need, all possible components may be downloaded on-demand to create a complete
268 Execute the following command from Command Prompt to download all possible
269 required files. Remember to substitute ``python-3.9.0.exe`` for the actual
275 python-3.9.0.exe /layout [optional target directory]
280 --------------------
286 "Modify" allows you to add or remove features by modifying the checkboxes -
298 .. _windows-store:
317 Alternatively, it will be available from any Command Prompt or PowerShell
325 select which version of Python is associated with each command. It is
329 Virtual environments can be created with ``python -m venv`` and activated
341 Python in Start and right-click to select Uninstall. Uninstalling will
346 ------------
356 At runtime, Python will use a private copy of well-known Windows folders and the registry.
367 .. code-block:: python
382 Microsoft'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>`_
387 .. _windows-nuget:
395 continuous integration and build systems that do not have a system-wide
397 perfectly fine for packages containing build-time tools.
399 Visit `nuget.org <https://www.nuget.org/>`_ for the most up-to-date information
403 The ``nuget.exe`` command line tool may be downloaded directly from
405 tool, the latest version of Python for 64-bit or 32-bit machines is installed
408 nuget.exe install python -ExcludeVersion -OutputDirectory .
409 nuget.exe install pythonx86 -ExcludeVersion -OutputDirectory .
411 To select a particular version, add a ``-Version 3.x.y``. The output directory
414 and without the ``-ExcludeVersion`` option this name will include the specific
418 .. code-block:: doscon
420 # Without -ExcludeVersion
421 > .\python.3.5.2\tools\python.exe -V
424 # With -ExcludeVersion
425 > .\python\tools\python.exe -V
429 installed side-by-side and referenced using the full path. Alternatively,
440 for the 64-bit version and `www.nuget.org/packages/pythonx86
441 <https://www.nuget.org/packages/pythonx86>`_ for the 32-bit version.
444 .. _windows-embeddable:
453 directly accessed by end-users.
457 installed packages. The standard library is included as pre-compiled and
465 …<https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist#visual-studio-2015-2017-2…
471 Third-party packages should be installed by the application installer alongside
475 general, third-party packages should be treated as part of the application
482 ------------------
495 able to call ``Py_Main`` with a hard-coded command line.
499 command-line arguments. In this case, the application will appear to be Python
509 ----------------
532 Installer with multi-platform compatibility, documentation, PyWin32
542 …thought.com/hc/en-us/articles/360038600051-Canopy-GUI-end-of-life-transition-to-the-Enthought-Depl…
545 Windows-specific distribution with prebuilt scientific packages and
556 To run Python conveniently from a command prompt, you might consider changing
559 reliable for a single, system-wide installation. If you regularly use multiple
563 .. _setting-envvars:
566 ---------------------------------------
569 User level and the System level, or temporarily in a command prompt.
571 To temporarily set environment variables, open Command Prompt and use the
572 :command:`set` command:
574 .. code-block:: doscon
593 System variables, you need non-restricted access to your machine
608 https://docs.microsoft.com/en-us/windows/win32/procthread/environment-variables
611 https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1
612 The ``set`` command, for temporarily modifying environment variables
614 https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx
615 The ``setx`` command, for permanently modifying environment variables
618 .. _windows-path-mod:
621 -----------------------------
626 interpreter, you might want to start Python in the command prompt. The
632 This allows you to type :command:`python` to run the interpreter, and
633 :command:`pip` for the package installer. Thus, you can also execute your
634 scripts with command line options, see :ref:`using-on-cmdline` documentation.
636 If you don't enable this option at install time, you can always re-run the
638 modify the :envvar:`PATH` using the directions in :ref:`setting-envvars`. You
646 .. _win-utf8-mode:
648 UTF-8 mode
657 This may cause issues because UTF-8 is widely used on the internet
660 You can use the :ref:`Python UTF-8 Mode <utf8-mode>` to change the default text
661 encoding to UTF-8. You can enable the :ref:`Python UTF-8 Mode <utf8-mode>` via
662 the ``-X utf8`` command line option, or the ``PYTHONUTF8=1`` environment
663 variable. See :envvar:`PYTHONUTF8` for enabling UTF-8 mode, and
664 :ref:`setting-envvars` for how to modify environment variables.
666 When the :ref:`Python UTF-8 Mode <utf8-mode>` is enabled, you can still use the
673 temporarily or use the ``-X utf8`` command line option.
676 Even when UTF-8 mode is disabled, Python uses UTF-8 by default
693 command-line) to indicate a preference for a specific Python version, and
697 appropriate version of Python. It will prefer per-user installations over
698 system-wide ones, and orders by language version rather than using the most
704 ---------------
706 From the command-line
711 System-wide installations of Python 3.3 and later will put the launcher on your
714 launcher is available, execute the following command in Command Prompt::
719 started - it can be exited as normal, and any additional command-line
723 will have noticed that Python |version| was started - to launch Python 3.7, try
724 the command::
726 py -3.7
729 command::
731 py -2
735 'py' is not recognized as an internal or external command,
738 The command::
740 py --list
744 The ``-x.y`` argument is the short form of the ``-V:Company/Tag`` argument,
747 :pep:`514` will be discoverable. The ``--list`` command lists all available
748 runtimes using the ``-V:`` format.
750 When using the ``-V:`` argument, specifying the Company will limit selection to
755 py -V:3
758 py -V:PythonCore/
761 py -V:PythonCore/3
763 The short form of the argument (``-3``) only ever selects from core Python
764 releases, and not other distributions. However, the longer form (``-V:3``) will
767 The Company is matched on the full string, case-insenitive. The Tag is matched
769 hyphen. This allows ``-V:3.1`` to match ``3.1-32``, but not ``3.10``. Tags are
771 compared using text (``-V:3.01`` does not match ``3.1``).
789 Let's create a test Python script - create a file called ``hello.py`` with the
792 .. code-block:: python
798 From the directory in which hello.py lives, execute the command::
805 .. code-block:: python
809 Re-executing the command should now print the latest Python 3.x information.
810 As with the above command-line examples, you can specify a more explicit
817 compatibility and for compatibility with Unix, where the command ``python``
825 when you double-click on one of these files from Windows explorer the launcher
832 Shebang Lines
833 -------------
836 "shebang" line. Linux and other Unix like operating systems have native
842 To allow shebang lines in Python scripts to be portable between Unix and
853 .. code-block:: sh
861 shebang lines starting with ``/usr``.
865 Furthermore the 32-bit version can be requested by adding "-32" after the
866 minor version. I.e. ``/usr/bin/python3.7-32`` will request usage of the
867 32-bit python 3.7.
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``).
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.
881 The ``/usr/bin/env`` form of shebang line has one further special property.
886 If an executable matching the first argument after the ``env`` command cannot
892 Shebang 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>`.
895 system. The name of the command must be a single argument (no spaces in the
896 shebang executable), and the value substituted is the full path to the
900 .. code-block:: ini
907 This is a convenience for Windows-only scripts, such as those generated by an
908 installer, since the behavior is not compatible with Unix-style shells.
913 Arguments in shebang lines
914 --------------------------
916 The shebang lines can also specify additional options to be passed to the
917 Python interpreter. For example, if you have a shebang line:
919 .. code-block:: sh
921 #! /usr/bin/python -v
923 Then Python will be started with the ``-v`` option
926 -------------
928 .. _launcher-ini:
933 Two .ini files will be searched by the launcher - ``py.ini`` in the current
946 In some cases, a version qualifier can be included in a command to dictate
947 which version of Python will be used by the command. A version qualifier
950 if a 32 or 64 bit implementation shall be requested by adding "-32" or "-64".
952 For example, a shebang line of ``#!python`` has no version qualifier, while
955 If no version qualifiers are found in a command, the environment
958 specify 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
970 On 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
972 preferred. This will be true for both 32-bit and 64-bit implementations of the
973 launcher - a 32-bit launcher will prefer to execute a 64-bit Python installation
977 whether a 32 or 64-bit version of Python and corresponding launcher was
978 installed last). As noted above, an optional "-32" or "-64" suffix can be
985 the command ``python3`` will use the latest Python 3.x installed.
987 * The command ``python3.7`` will not consult any
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
1012 .. code-block:: ini
1020 .. code-block:: ini
1027 -----------
1033 particular version was chosen and the exact command-line used to execute the
1037 -------
1040 the launcher will output the command it would have run, but will not actually
1042 detect and then launch Python directly. Note that the command written to
1043 standard output is always encoded using UTF-8, and may not render correctly in
1047 -----------------
1052 user interaction to complete, and you may need to run the command again.
1059 ------------
1068 +-------------------+-------+-----------------------------------------------+
1072 +-------------------+-------+-----------------------------------------------+
1074 +-------------------+-------+-----------------------------------------------+
1075 | RC_INSTALLING | 111 | An install was started, but the command will |
1076 | | | need to be re-run after it completes. |
1077 +-------------------+-------+-----------------------------------------------+
1079 +-------------------+-------+-----------------------------------------------+
1080 | RC_NO_COMMANDLINE | 108 | Unable to obtain command line from the |
1082 +-------------------+-------+-----------------------------------------------+
1084 +-------------------+-------+-----------------------------------------------+
1087 +-------------------+-------+-----------------------------------------------+
1095 These notes supplement the description at :ref:`sys-path-init` with
1105 :ref:`using-on-envvars`, its entries are added next. Note that on Windows,
1112 semicolon-delimited path strings as their default value will cause each path
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
1126 relative entries is used (e.g. ``.\Lib;.\plat-win``, etc).
1171 These will ensure that the files in a system-wide installation will not take
1175 non-standard paths in the registry and user site-packages.
1200 The Windows-specific standard modules are documented in
1201 :ref:`mswin-specific-services`.
1204 -------
1207 is a collection of modules for advanced Windows-specific support. This includes
1211 <https://docs.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal>`_
1217 <https://docs.microsoft.com/en-us/cpp/mfc/mfc-desktop-applications>`_
1222 shipped with PyWin32. It is an embeddable IDE with a built-in debugger.
1234 ---------
1236 `cx_Freeze <https://cx-freeze.readthedocs.io/en/latest/>`_ is a :mod:`distutils`
1237 extension (see :ref:`extending-distutils`) which wraps Python scripts into
1249 <https://devguide.python.org/setup/#get-the-source-code>`_.
1257 For extension modules, consult :ref:`building-on-windows`.
1275 for detailed information about platforms with pre-compiled installers.