-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathwindows.html
More file actions
2461 lines (2408 loc) · 189 KB
/
Copy pathwindows.html
File metadata and controls
2461 lines (2408 loc) · 189 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="fa" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="4. Using Python on Windows" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/using/windows.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="This document aims to give an overview of Windows-specific behaviour you should know about when using Python on Microsoft Windows. Unlike most Unix systems and services, Windows does not include a ..." />
<meta property="og:image" content="_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="This document aims to give an overview of Windows-specific behaviour you should know about when using Python on Microsoft Windows. Unlike most Unix systems and services, Windows does not include a ..." />
<meta name="theme-color" content="#3776ab">
<meta property="og:image:width" content="200">
<meta property="og:image:height" content="200">
<title>4. Using Python on Windows — مستندات Python3.14.6</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=4365c8fe" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
<script src="../_static/documentation_options.js?v=e254dbbb"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/translations.js?v=5df48d09"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="جستجو در مستندات Python3.14.6"
href="../_static/opensearch.xml"/>
<link rel="author" title="درباره این مستندات" href="../about.html" />
<link rel="index" title="فهرست" href="../genindex.html" />
<link rel="search" title="جستجو" href="../search.html" />
<link rel="copyright" title="حق چاپ" href="../copyright.html" />
<link rel="next" title="5. Using Python on macOS" href="mac.html" />
<link rel="prev" title="3. Configure Python" href="configure.html" />
<link rel="canonical" href="https://docs.python.org/3/using/windows.html">
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg">
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/search-focus.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
<script type="text/javascript" src="../_static/rtd_switcher.js"></script>
<meta name="readthedocs-addons-api-version" content="1">
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Python logo">
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
</svg>
<input placeholder="جستجو سریع" aria-label="جستجو سریع" type="search" name="q">
<input type="submit" value="برو">
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h3><a href="../contents.html">فهرست عناوین</a></h3>
<ul>
<li><a class="reference internal" href="#">4. Using Python on Windows</a><ul>
<li><a class="reference internal" href="#python-install-manager">4.1. Python install manager</a><ul>
<li><a class="reference internal" href="#installation">4.1.1. Installation</a></li>
<li><a class="reference internal" href="#basic-use">4.1.2. Basic use</a></li>
<li><a class="reference internal" href="#command-help">4.1.3. Command help</a></li>
<li><a class="reference internal" href="#listing-runtimes">4.1.4. Listing runtimes</a></li>
<li><a class="reference internal" href="#installing-runtimes">4.1.5. Installing runtimes</a></li>
<li><a class="reference internal" href="#offline-installs">4.1.6. Offline installs</a></li>
<li><a class="reference internal" href="#uninstalling-runtimes">4.1.7. Uninstalling runtimes</a></li>
<li><a class="reference internal" href="#configuration">4.1.8. Configuration</a></li>
<li><a class="reference internal" href="#shebang-lines">4.1.9. Shebang lines</a></li>
<li><a class="reference internal" href="#advanced-installation">4.1.10. Advanced installation</a></li>
<li><a class="reference internal" href="#administrative-configuration">4.1.11. Administrative configuration</a></li>
<li><a class="reference internal" href="#installing-free-threaded-binaries">4.1.12. Installing free-threaded binaries</a></li>
<li><a class="reference internal" href="#index-signatures">4.1.13. Index signatures</a></li>
<li><a class="reference internal" href="#troubleshooting">4.1.14. Troubleshooting</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-embeddable-package">4.2. The embeddable package</a><ul>
<li><a class="reference internal" href="#python-application">4.2.1. Python application</a></li>
<li><a class="reference internal" href="#embedding-python">4.2.2. Embedding Python</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-nuget-org-packages">4.3. The nuget.org packages</a><ul>
<li><a class="reference internal" href="#free-threaded-packages">4.3.1. Free-threaded packages</a></li>
</ul>
</li>
<li><a class="reference internal" href="#alternative-bundles">4.4. Alternative bundles</a></li>
<li><a class="reference internal" href="#supported-windows-versions">4.5. Supported Windows versions</a></li>
<li><a class="reference internal" href="#removing-the-max-path-limitation">4.6. Removing the MAX_PATH limitation</a></li>
<li><a class="reference internal" href="#utf-8-mode">4.7. UTF-8 mode</a></li>
<li><a class="reference internal" href="#finding-modules">4.8. Finding modules</a></li>
<li><a class="reference internal" href="#additional-modules">4.9. Additional modules</a><ul>
<li><a class="reference internal" href="#pywin32">4.9.1. PyWin32</a></li>
<li><a class="reference internal" href="#cx-freeze">4.9.2. cx_Freeze</a></li>
</ul>
</li>
<li><a class="reference internal" href="#compiling-python-on-windows">4.10. Compiling Python on Windows</a></li>
<li><a class="reference internal" href="#the-full-installer-deprecated">4.11. The full installer (deprecated)</a><ul>
<li><a class="reference internal" href="#installation-steps">4.11.1. Installation steps</a></li>
<li><a class="reference internal" href="#id2">4.11.2. Removing the MAX_PATH limitation</a></li>
<li><a class="reference internal" href="#installing-without-ui">4.11.3. Installing without UI</a></li>
<li><a class="reference internal" href="#installing-without-downloading">4.11.4. Installing without downloading</a></li>
<li><a class="reference internal" href="#modifying-an-install">4.11.5. Modifying an install</a></li>
<li><a class="reference internal" href="#id3">4.11.6. Installing free-threaded binaries</a></li>
</ul>
</li>
<li><a class="reference internal" href="#python-launcher-for-windows-deprecated">4.12. Python launcher for Windows (deprecated)</a><ul>
<li><a class="reference internal" href="#getting-started">4.12.1. Getting started</a><ul>
<li><a class="reference internal" href="#from-the-command-line">4.12.1.1. From the command-line</a></li>
<li><a class="reference internal" href="#virtual-environments">4.12.1.2. Virtual environments</a></li>
<li><a class="reference internal" href="#from-a-script">4.12.1.3. From a script</a></li>
<li><a class="reference internal" href="#from-file-associations">4.12.1.4. From file associations</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id4">4.12.2. Shebang lines</a></li>
<li><a class="reference internal" href="#arguments-in-shebang-lines">4.12.3. Arguments in shebang lines</a></li>
<li><a class="reference internal" href="#customization">4.12.4. Customization</a><ul>
<li><a class="reference internal" href="#customization-via-ini-files">4.12.4.1. Customization via INI files</a></li>
<li><a class="reference internal" href="#customizing-default-python-versions">4.12.4.2. Customizing default Python versions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#diagnostics">4.12.5. Diagnostics</a></li>
<li><a class="reference internal" href="#dry-run">4.12.6. Dry run</a></li>
<li><a class="reference internal" href="#install-on-demand">4.12.7. Install on demand</a></li>
<li><a class="reference internal" href="#return-codes">4.12.8. Return codes</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>موضوع قبلی</h4>
<p class="topless"><a href="configure.html"
title="فصل قبلی"><span class="section-number">3. </span>Configure Python</a></p>
</div>
<div>
<h4>موضوع بعدی</h4>
<p class="topless"><a href="mac.html"
title="فصل بعدی"><span class="section-number">5. </span>Using Python on macOS</a></p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const title = document.querySelector('meta[property="og:title"]').content;
const elements = document.querySelectorAll('.improvepage');
const pageurl = window.location.href.split('?')[0];
elements.forEach(element => {
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
url.searchParams.set('pagetitle', title);
url.searchParams.set('pageurl', pageurl);
url.searchParams.set('pagesource', "using/windows.rst");
element.href = url.toString();
});
});
</script>
<div role="note" aria-label="source link">
<h3>این صفحه</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">گزارش یک اشکال</a></li>
<li><a class="improvepage" href="../improve-page-nojs.html">بهبود این صفحه</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/windows.rst?plain=1"
rel="nofollow">نمایش منبع
</a>
</li>
<li>
<a href="https://github.com/python/python-docs-fa/blob/3.14/using/windows.po?plain=1"
rel="nofollow">نمایش منبع ترجمه</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>ناوبری</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="فهرست کلی"
accesskey="I">فهرست</a></li>
<li class="right" >
<a href="../py-modindex.html" title="نمایه ی ماژول های پایتون"
>ماژول ها</a> |</li>
<li class="right" >
<a href="mac.html" title="5. Using Python on macOS"
accesskey="N">بعدی</a> |</li>
<li class="right" >
<a href="configure.html" title="3. Configure Python"
accesskey="P">قبلی</a> |</li>
<li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.14.6 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Setup and Usage</a> »</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">4. </span>Using Python on Windows</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="جستجو سریع" aria-label="جستجو سریع" type="search" name="q" id="search-box">
<input type="submit" value="برو">
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="using-python-on-windows">
<span id="using-on-windows"></span><h1><span class="section-number">4. </span>Using Python on Windows<a class="headerlink" href="#using-python-on-windows" title="Link to this heading">¶</a></h1>
<p>This document aims to give an overview of Windows-specific behaviour you should
know about when using Python on Microsoft Windows.</p>
<p>Unlike most Unix systems and services, Windows does not include a system
supported installation of Python. Instead, Python can be obtained from a number
of distributors, including directly from the CPython team. Each Python
distribution will have its own benefits and drawbacks, however, consistency with
other tools you are using is generally a worthwhile benefit. Before committing
to the process described here, we recommend investigating your existing tools to
see if they can provide Python directly.</p>
<p>To obtain Python from the CPython team, use the Python Install Manager. This
is a standalone tool that makes Python available as global commands on your
Windows machine, integrates with the system, and supports updates over time. You
can download the Python Install Manager from <a class="reference external" href="https://www.python.org/downloads/">python.org/downloads</a> or through
the <a class="reference external" href="https://apps.microsoft.com/detail/9NQ7512CXL7T">Microsoft Store app</a>.</p>
<p>Once you have installed the Python Install Manager, the global <code class="docutils literal notranslate"><span class="pre">python</span></code>
command can be used from any terminal to launch your current latest version of
Python. This version may change over time as you add or remove different
versions, and the <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">list</span></code> command will show which is current.</p>
<p>In general, we recommend that you create a <a class="reference internal" href="../tutorial/venv.html#tut-venv"><span class="std std-ref">virtual environment</span></a>
for each project and run <code class="docutils literal notranslate"><span class="pre"><env>\Scripts\Activate</span></code> in your terminal to use it.
This provides isolation between projects, consistency over time, and ensures
that additional commands added by packages are also available in your session.
Create a virtual environment using <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">venv</span> <span class="pre"><env</span> <span class="pre">path></span></code>.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">python</span></code> or <code class="docutils literal notranslate"><span class="pre">py</span></code> commands do not seem to be working, please see the
<a class="reference internal" href="#pymanager-troubleshoot"><span class="std std-ref">Troubleshooting</span></a> section below. There are
sometimes additional manual steps required to configure your PC.</p>
<p>Apart from using the Python install manager, Python can also be obtained as
NuGet packages. See <a class="reference internal" href="#windows-nuget"><span class="std std-ref">The nuget.org packages</span></a> below for more information on these
packages.</p>
<p>The embeddable distros are minimal packages of Python suitable for embedding
into larger applications. They can be installed using the Python install
manager. See <a class="reference internal" href="#windows-embeddable"><span class="std std-ref">The embeddable package</span></a> below for more information on these
packages.</p>
<section id="python-install-manager">
<span id="launcher"></span><span id="windows-path-mod"></span><span id="setting-envvars"></span><span id="windows-store"></span><span id="pymanager"></span><h2><span class="section-number">4.1. </span>Python install manager<a class="headerlink" href="#python-install-manager" title="Link to this heading">¶</a></h2>
<section id="installation">
<h3><span class="section-number">4.1.1. </span>Installation<a class="headerlink" href="#installation" title="Link to this heading">¶</a></h3>
<p>The Python install manager can be installed from the <a class="reference external" href="https://apps.microsoft.com/detail/9NQ7512CXL7T">Microsoft Store app</a>
or downloaded and installed from <a class="reference external" href="https://www.python.org/downloads/">python.org/downloads</a>. The two versions are
identical.</p>
<p>To install through the Store, simply click "Install". After it has completed,
open a terminal and type <code class="docutils literal notranslate"><span class="pre">python</span></code> to get started.</p>
<p>To install the file downloaded from python.org, either double-click and select
"Install", or run <code class="docutils literal notranslate"><span class="pre">Add-AppxPackage</span> <span class="pre"><path</span> <span class="pre">to</span> <span class="pre">MSIX></span></code> in Windows Powershell.</p>
<p>After installation, the <code class="docutils literal notranslate"><span class="pre">python</span></code>, <code class="docutils literal notranslate"><span class="pre">py</span></code>, and <code class="docutils literal notranslate"><span class="pre">pymanager</span></code> commands should be
available. If you have existing installations of Python, or you have modified
your <span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> variable, you may need to remove them or undo the
modifications. See <a class="reference internal" href="#pymanager-troubleshoot"><span class="std std-ref">Troubleshooting</span></a> for more help with fixing
non-working commands.</p>
<p>When you first install a runtime, you will likely be prompted to add a directory
to your <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>. This is optional, if you prefer to use the <code class="docutils literal notranslate"><span class="pre">py</span></code>
command, but is offered for those who prefer the full range of aliases (such
as <code class="docutils literal notranslate"><span class="pre">python3.14.exe</span></code>) to be available. The directory will be
<code class="file docutils literal notranslate"><span class="pre">%LocalAppData%\Python\bin</span></code> by default, but may be customized by an
administrator. Click Start and search for "Edit environment variables for your
account" for the system settings page to add the path.</p>
<p>Each Python runtime you install will have its own directory for scripts. These
also need to be added to <span class="target" id="index-2"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> if you want to use them.</p>
<p>The Python install manager will be automatically updated to new releases. This
does not affect any installs of Python runtimes. Uninstalling the Python install
manager does not uninstall any Python runtimes.</p>
<p>If you are not able to install an MSIX in your context, for example, you are
using automated deployment software that does not support it, or are targeting
Windows Server 2019, please see <a class="reference internal" href="#pymanager-advancedinstall"><span class="std std-ref">Advanced installation</span></a> below for more
information.</p>
</section>
<section id="basic-use">
<h3><span class="section-number">4.1.2. </span>Basic use<a class="headerlink" href="#basic-use" title="Link to this heading">¶</a></h3>
<p>The recommended command for launching Python is <code class="docutils literal notranslate"><span class="pre">python</span></code>, which will either
launch the version requested by the script being launched, an active virtual
environment, or the default installed version, which will be the latest stable
release unless configured otherwise. If no version is specifically requested and
no runtimes are installed at all, the current latest release will be installed
automatically.</p>
<p>For all scenarios involving multiple runtime versions, the recommended command
is <code class="docutils literal notranslate"><span class="pre">py</span></code>. This may be used anywhere in place of <code class="docutils literal notranslate"><span class="pre">python</span></code> or the older
<code class="docutils literal notranslate"><span class="pre">py.exe</span></code> launcher. By default, <code class="docutils literal notranslate"><span class="pre">py</span></code> matches the behaviour of <code class="docutils literal notranslate"><span class="pre">python</span></code>, but
also allows command line options to select a specific version as well as
subcommands to manage installations. These are detailed below.</p>
<p>Because the <code class="docutils literal notranslate"><span class="pre">py</span></code> command may already be taken by the previous version, there
is also an unambiguous <code class="docutils literal notranslate"><span class="pre">pymanager</span></code> command. Scripted installs that are
intending to use Python install manager should consider using <code class="docutils literal notranslate"><span class="pre">pymanager</span></code>, due
to the lower chance of encountering a conflict with existing installs. The only
difference between the two commands is when running without any arguments:
<code class="docutils literal notranslate"><span class="pre">py</span></code> will launch your default interpreter, while <code class="docutils literal notranslate"><span class="pre">pymanager</span></code> will display
help (<code class="docutils literal notranslate"><span class="pre">pymanager</span> <span class="pre">exec</span> <span class="pre">...</span></code> provides equivalent behaviour to <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">...</span></code>).</p>
<p>Each of these commands also has a windowed version that avoids creating a
console window. These are <code class="docutils literal notranslate"><span class="pre">pyw</span></code>, <code class="docutils literal notranslate"><span class="pre">pythonw</span></code> and <code class="docutils literal notranslate"><span class="pre">pymanagerw</span></code>. A <code class="docutils literal notranslate"><span class="pre">python3</span></code>
command is also included that mimics the <code class="docutils literal notranslate"><span class="pre">python</span></code> command. It is intended to
catch accidental uses of the typical POSIX command on Windows, but is not meant
to be widely used or recommended.</p>
<p>To launch your default runtime, run <code class="docutils literal notranslate"><span class="pre">python</span></code> or <code class="docutils literal notranslate"><span class="pre">py</span></code> with the arguments you
want to be passed to the runtime (such as script files or the module to launch):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py
...
$> python my-script.py
...
$> py -m this
...
</pre></div>
</div>
<p>The default runtime can be overridden with the <span class="target" id="index-3"></span><a class="reference internal" href="#envvar-PYTHON_MANAGER_DEFAULT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_MANAGER_DEFAULT</span></code></a>
environment variable, or a configuration file. See <a class="reference internal" href="#pymanager-config"><span class="std std-ref">Configuration</span></a> for
information about configuration settings.</p>
<p>To launch a specific runtime, the <code class="docutils literal notranslate"><span class="pre">py</span></code> command accepts a <code class="docutils literal notranslate"><span class="pre">-V:<TAG></span></code> option.
This option must be specified before any others. The tag is part or all of the
identifier for the runtime; for those from the CPython team, it looks like the
version, potentially with the platform. For compatibility, the <code class="docutils literal notranslate"><span class="pre">V:</span></code> may be
omitted in cases where the tag refers to an official release and starts with
<code class="docutils literal notranslate"><span class="pre">3</span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py -V:3.14 ...
$> py -V:3-arm64 ...
</pre></div>
</div>
<p>Runtimes from other distributors may require the <em>company</em> to be included as
well. This should be separated from the tag by a slash, and may be a prefix.
Specifying the company is optional when it is <code class="docutils literal notranslate"><span class="pre">PythonCore</span></code>, and specifying the
tag is optional (but not the slash) when you want the latest release from a
specific company.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py -V:Distributor\1.0 ...
$> py -V:distrib/ ...
</pre></div>
</div>
<p>If no version is specified, but a script file is passed, the script will be
inspected for a <em>shebang line</em>. This is a special format for the first line in
a file that allows overriding the command. See <a class="reference internal" href="#pymanager-shebang"><span class="std std-ref">Shebang lines</span></a> for more
information. When there is no shebang line, or it cannot be resolved, the script
will be launched with the default runtime.</p>
<p>If you are running in an active virtual environment, have not requested a
particular version, and there is no shebang line, the default runtime will be
that virtual environment. In this scenario, the <code class="docutils literal notranslate"><span class="pre">python</span></code> command was likely
already overridden and none of these checks occurred. However, this behaviour
ensures that the <code class="docutils literal notranslate"><span class="pre">py</span></code> command can be used interchangeably.</p>
<p>When no runtimes are installed, any launch command will try to install the
requested version and launch it. However, after any version is installed, only
the <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">exec</span> <span class="pre">...</span></code> and <code class="docutils literal notranslate"><span class="pre">pymanager</span> <span class="pre">exec</span> <span class="pre">...</span></code> commands will install if the
requested version is absent. Other forms of commands will display an error and
direct you to use <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">install</span></code> first.</p>
</section>
<section id="command-help">
<h3><span class="section-number">4.1.3. </span>Command help<a class="headerlink" href="#command-help" title="Link to this heading">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">help</span></code> command will display the full list of supported commands, along
with their options. Any command may be passed the <code class="docutils literal notranslate"><span class="pre">-?</span></code> option to display its
help, or its name passed to <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">help</span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py help
$> py help install
$> py install /?
</pre></div>
</div>
<p>All commands support some common options, which will be shown by <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">help</span></code>.
These options must be specified after any subcommand. Specifying <code class="docutils literal notranslate"><span class="pre">-v</span></code> or
<code class="docutils literal notranslate"><span class="pre">--verbose</span></code> will increase the amount of output shown, and <code class="docutils literal notranslate"><span class="pre">-vv</span></code> will
increase it further for debugging purposes. Passing <code class="docutils literal notranslate"><span class="pre">-q</span></code> or <code class="docutils literal notranslate"><span class="pre">--quiet</span></code> will
reduce output, and <code class="docutils literal notranslate"><span class="pre">-qq</span></code> will reduce it further.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">--config=<PATH></span></code> option allows specifying a configuration file to
override multiple settings at once. See <a class="reference internal" href="#pymanager-config"><span class="std std-ref">Configuration</span></a> below for more
information about these files.</p>
</section>
<section id="listing-runtimes">
<h3><span class="section-number">4.1.4. </span>Listing runtimes<a class="headerlink" href="#listing-runtimes" title="Link to this heading">¶</a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py list [-f=|--format=<FMT>] [-1|--one] [--online|-s=|--source=<URL>] [<TAG>...]
</pre></div>
</div>
<p>The list of installed runtimes can be seen using <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">list</span></code>. A filter may be
added in the form of one or more tags (with or without company specifier), and
each may include a <code class="docutils literal notranslate"><span class="pre"><</span></code>, <code class="docutils literal notranslate"><span class="pre"><=</span></code>, <code class="docutils literal notranslate"><span class="pre">>=</span></code> or <code class="docutils literal notranslate"><span class="pre">></span></code> prefix to restrict to a range.</p>
<p>A range of formats are supported, and can be passed as the <code class="docutils literal notranslate"><span class="pre">--format=<FMT></span></code> or
<code class="docutils literal notranslate"><span class="pre">-f</span> <span class="pre"><FMT></span></code> option. Formats include <code class="docutils literal notranslate"><span class="pre">table</span></code> (a user friendly table view),
<code class="docutils literal notranslate"><span class="pre">csv</span></code> (comma-separated table), <code class="docutils literal notranslate"><span class="pre">json</span></code> (a single JSON blob), <code class="docutils literal notranslate"><span class="pre">jsonl</span></code> (one
JSON blob per result), <code class="docutils literal notranslate"><span class="pre">exe</span></code> (just the executable path), <code class="docutils literal notranslate"><span class="pre">prefix</span></code> (just the
prefix path).</p>
<p>The <code class="docutils literal notranslate"><span class="pre">--one</span></code> or <code class="docutils literal notranslate"><span class="pre">-1</span></code> option only displays a single result. If the default
runtime is included, it will be the one. Otherwise, the "best" result is shown
("best" is deliberately vaguely defined, but will usually be the most recent
version). The result shown by <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">list</span> <span class="pre">--one</span> <span class="pre"><TAG></span></code> will match the runtime
that would be launched by <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-V:<TAG></span></code>.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">--only-managed</span></code> option excludes results that were not installed by the
Python install manager. This is useful when determining which runtimes may be
updated or uninstalled through the <code class="docutils literal notranslate"><span class="pre">py</span></code> command.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">--online</span></code> option is short for passing <code class="docutils literal notranslate"><span class="pre">--source=<URL></span></code> with the default
source. Passing either of these options will search the online index for
runtimes that can be installed. The result shown by <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">list</span> <span class="pre">--online</span> <span class="pre">--one</span>
<span class="pre"><TAG></span></code> will match the runtime that would be installed by <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">install</span> <span class="pre"><TAG></span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py list --online 3.14
</pre></div>
</div>
<p>For compatibility with the old launcher, the <code class="docutils literal notranslate"><span class="pre">--list</span></code>, <code class="docutils literal notranslate"><span class="pre">--list-paths</span></code>,
<code class="docutils literal notranslate"><span class="pre">-0</span></code> and <code class="docutils literal notranslate"><span class="pre">-0p</span></code> commands (e.g. <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-0p</span></code>) are retained. They do not allow
additional options, and will produce legacy formatted output.</p>
</section>
<section id="installing-runtimes">
<h3><span class="section-number">4.1.5. </span>Installing runtimes<a class="headerlink" href="#installing-runtimes" title="Link to this heading">¶</a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py install [-s=|--source=<URL>] [-f|--force] [-u|--update] [--dry-run] [<TAG>...]
</pre></div>
</div>
<p>New runtime versions may be added using <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">install</span></code>. One or more tags may be
specified, and the special tag <code class="docutils literal notranslate"><span class="pre">default</span></code> may be used to select the default.
Ranges are not supported for installation.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">--source=<URL></span></code> option allows overriding the online index that is used to
obtain runtimes. This may be used with an offline index, as shown in
<a class="reference internal" href="#pymanager-offline"><span class="std std-ref">Offline installs</span></a>.</p>
<p>Passing <code class="docutils literal notranslate"><span class="pre">--force</span></code> will ignore any cached files and remove any existing install
to replace it with the specified one.</p>
<p>Passing <code class="docutils literal notranslate"><span class="pre">--update</span></code> will replace existing installs if the new version is newer.
Otherwise, they will be left. If no tags are provided with <code class="docutils literal notranslate"><span class="pre">--update</span></code>, all
installs managed by the Python install manager will be updated if newer versions
are available. Updates will remove any modifications made to the install,
including globally installed packages, but virtual environments will continue to
work.</p>
<p>Passing <code class="docutils literal notranslate"><span class="pre">--dry-run</span></code> will generate output and logs, but will not modify any
installs.</p>
<p>Passing <code class="docutils literal notranslate"><span class="pre">--refresh</span></code> will update all registrations for installed runtimes. This
will recreate Start menu shortcuts, registry keys, and global aliases (such as
<code class="docutils literal notranslate"><span class="pre">python3.14.exe</span></code> or for any installed scripts). These are automatically
refreshed on installation of any runtime, but may need to be manually refreshed
after installing packages.</p>
<p>In addition to the above options, the <code class="docutils literal notranslate"><span class="pre">--target</span></code> option will extract the
runtime to the specified directory instead of doing a normal install.
This is useful for embedding runtimes into larger applications.
Unlike a normal install, <code class="docutils literal notranslate"><span class="pre">py</span></code> will not be aware of the extracted runtime,
and no Start menu or other shortcuts will be created.
To launch the runtime, directly execute the main executable (typically
<code class="docutils literal notranslate"><span class="pre">python.exe</span></code>) in the target directory.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py install ... [-t=|--target=<PATH>] <TAG>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">exec</span></code> command will install the requested runtime if it is not already
present. This is controlled by the <code class="docutils literal notranslate"><span class="pre">automatic_install</span></code> configuration
(<span class="target" id="index-4"></span><a class="reference internal" href="#envvar-PYTHON_MANAGER_AUTOMATIC_INSTALL"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_MANAGER_AUTOMATIC_INSTALL</span></code></a>), and is enabled by default.
If no runtimes are available at all, all launch commands will do an automatic
install if the configuration setting allows. This is to ensure a good experience
for new users, but should not generally be relied on rather than using the
<code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">exec</span></code> command or explicit install commands.</p>
</section>
<section id="offline-installs">
<span id="pymanager-offline"></span><h3><span class="section-number">4.1.6. </span>Offline installs<a class="headerlink" href="#offline-installs" title="Link to this heading">¶</a></h3>
<p>To perform offline installs of Python, you will need to first create an offline
index on a machine that has network access.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py install --download=<PATH> ... <TAG>...
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">--download=<PATH></span></code> option will download the packages for the listed tags
and create a directory containing them and an <code class="docutils literal notranslate"><span class="pre">index.json</span></code> file suitable for
later installation. This entire directory can be moved to the offline machine
and used to install one or more of the bundled runtimes:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py install --source="<PATH>\index.json" <TAG>...
</pre></div>
</div>
<p>The Python install manager can be installed by downloading its installer and
moving it to another machine before installing.</p>
<p>Alternatively, the ZIP files in an offline index directory can simply be
transferred to another machine and extracted. This will not register the install
in any way, and so it must be launched by directly referencing the executables
in the extracted directory, but it is sometimes a preferable approach in cases
where installing the Python install manager is not possible or convenient.</p>
<p>In this way, Python runtimes can be installed and managed on a machine without
access to the internet.</p>
</section>
<section id="uninstalling-runtimes">
<h3><span class="section-number">4.1.7. </span>Uninstalling runtimes<a class="headerlink" href="#uninstalling-runtimes" title="Link to this heading">¶</a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py uninstall [-y|--yes] <TAG>...
</pre></div>
</div>
<p>Runtimes may be removed using the <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">uninstall</span></code> command. One or more tags
must be specified. Ranges are not supported here.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">--yes</span></code> option bypasses the confirmation prompt before uninstalling.</p>
<p>Instead of passing tags individually, the <code class="docutils literal notranslate"><span class="pre">--purge</span></code> option may be specified.
This will remove all runtimes managed by the Python install manager, including
cleaning up the Start menu, registry, and any download caches. Runtimes that
were not installed by the Python install manager will not be impacted, and
neither will manually created configuration files.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py uninstall [-y|--yes] --purge
</pre></div>
</div>
<p>The Python install manager can be uninstalled through the Windows "Installed
apps" settings page. This does not remove any runtimes, and they will still be
usable, though the global <code class="docutils literal notranslate"><span class="pre">python</span></code> and <code class="docutils literal notranslate"><span class="pre">py</span></code> commands will be removed.
Reinstalling the Python install manager will allow you to manage these runtimes
again. To completely clean up all Python runtimes, run with <code class="docutils literal notranslate"><span class="pre">--purge</span></code> before
uninstalling the Python install manager.</p>
</section>
<section id="configuration">
<span id="pymanager-config"></span><h3><span class="section-number">4.1.8. </span>Configuration<a class="headerlink" href="#configuration" title="Link to this heading">¶</a></h3>
<p>Python install manager is configured with a hierarchy of configuration files,
environment variables, command-line options, and registry settings. In general,
configuration files have the ability to configure everything, including the
location of other configuration files, while registry settings are
administrator-only and will override configuration files. Command-line options
override all other settings, but not every option is available.</p>
<p>This section will describe the defaults, but be aware that modified or
overridden installs may resolve settings differently.</p>
<p>A global configuration file may be configured by an administrator, and would be
read first. The user configuration file is stored at
<code class="file docutils literal notranslate"><span class="pre">%AppData%\Python\pymanager.json</span></code>
(note that this location is under <code class="docutils literal notranslate"><span class="pre">Roaming</span></code>, not <code class="docutils literal notranslate"><span class="pre">Local</span></code>) and is read next,
overwriting any settings from earlier files. An additional configuration file
may be specified as the <code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_CONFIG</span></code> environment variable or the
<code class="docutils literal notranslate"><span class="pre">--config</span></code> command line option (but not both).
These locations may be modified by administrative customization options listed
later.</p>
<p>The following settings are those that are considered likely to be modified in
normal use. Later sections list those that are intended for administrative
customization.</p>
<p class="rubric">Standard configuration options</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Config Key</p></th>
<th class="head"><p>Environment Variable</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">default_tag</span></code></p></td>
<td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-PYTHON_MANAGER_DEFAULT">
<span class="sig-name descname"><span class="pre">PYTHON_MANAGER_DEFAULT</span></span><a class="headerlink" href="#envvar-PYTHON_MANAGER_DEFAULT" title="Link to this definition">¶</a></dt>
<dd></dd></dl>
</td>
<td><p>The preferred default version to launch or install.
By default, this is interpreted as the most recent non-prerelease version
from the CPython team.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">default_platform</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_DEFAULT_PLATFORM</span></code></p></td>
<td><p>The preferred default platform to launch or install.
This is treated as a suffix to the specified tag, such that <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-V:3.14</span></code>
would prefer an install for <code class="docutils literal notranslate"><span class="pre">3.14-64</span></code> if it exists
(and <code class="docutils literal notranslate"><span class="pre">default_platform</span></code> is <code class="docutils literal notranslate"><span class="pre">-64</span></code>),
but will use <code class="docutils literal notranslate"><span class="pre">3.14</span></code> if no tagged install exists.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">logs_dir</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_LOGS</span></code></p></td>
<td><p>The location where log files are written.
By default, <code class="file docutils literal notranslate"><span class="pre">%TEMP%</span></code>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">automatic_install</span></code></p></td>
<td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-PYTHON_MANAGER_AUTOMATIC_INSTALL">
<span class="sig-name descname"><span class="pre">PYTHON_MANAGER_AUTOMATIC_INSTALL</span></span><a class="headerlink" href="#envvar-PYTHON_MANAGER_AUTOMATIC_INSTALL" title="Link to this definition">¶</a></dt>
<dd></dd></dl>
</td>
<td><p>True to allow automatic installs when using <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">exec</span></code> to launch (or
<code class="docutils literal notranslate"><span class="pre">py</span></code> when no runtimes are installed yet).
Other commands will not automatically install, regardless of this
setting.
By default, true.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">include_unmanaged</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_INCLUDE_UNMANAGED</span></code></p></td>
<td><p>True to allow listing and launching runtimes that were not installed
by the Python install manager, or false to exclude them.
By default, true.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">shebang_can_run_anything</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_SHEBANG_CAN_RUN_ANYTHING</span></code></p></td>
<td><p>True to allow shebangs in <code class="docutils literal notranslate"><span class="pre">.py</span></code> files to launch applications other than
Python runtimes, or false to prevent it.
By default, true.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">shebang_templates</span></code></p></td>
<td><p>(none)</p></td>
<td><p>Mapping from shebang line template to alternative command, such as
<code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-V:<tag></span></code> or a substitute string.
See <a class="reference internal" href="#pymanager-shebang"><span class="std std-ref">Shebang lines</span></a> for more details.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">log_level</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYMANAGER_VERBOSE</span></code>, <code class="docutils literal notranslate"><span class="pre">PYMANAGER_DEBUG</span></code></p></td>
<td><p>Set the default level of output (0-50).
By default, 20.
Lower values produce more output.
The environment variables are boolean, and may produce additional
output during startup that is later suppressed by other configuration.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">confirm</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_CONFIRM</span></code></p></td>
<td><p>True to confirm certain actions before taking them (such as uninstall),
or false to skip the confirmation.
By default, true.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">install.source</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_SOURCE_URL</span></code></p></td>
<td><p>Override the index feed to obtain new installs from.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">install.enable_entrypoints</span></code></p></td>
<td><p>(none)</p></td>
<td><p>True to generate global commands for installed packages (such as
<code class="docutils literal notranslate"><span class="pre">pip.exe</span></code>). These are defined by the packages themselves.
If set to false, only the Python interpreter has global commands created.
By default, true. You should run <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">install</span> <span class="pre">--refresh</span></code> after changing
this setting.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">list.format</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">PYTHON_MANAGER_LIST_FORMAT</span></code></p></td>
<td><p>Specify the default format used by the <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">list</span></code> command.
By default, <code class="docutils literal notranslate"><span class="pre">table</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">install_dir</span></code></p></td>
<td><p>(none)</p></td>
<td><p>Specify the root directory that runtimes will be installed into.
If you change this setting, previously installed runtimes will not be
usable unless you move them to the new location.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">global_dir</span></code></p></td>
<td><p>(none)</p></td>
<td><p>Specify the directory where global commands (such as <code class="docutils literal notranslate"><span class="pre">python3.14.exe</span></code>
and <code class="docutils literal notranslate"><span class="pre">pip.exe</span></code>) are stored.
This directory should be added to your <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> to make the
commands available from your terminal.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">download_dir</span></code></p></td>
<td><p>(none)</p></td>
<td><p>Specify the directory where downloaded files are stored.
This directory is a temporary cache, and can be cleaned up from time to
time.</p></td>
</tr>
</tbody>
</table>
<p>Dotted names should be nested inside JSON objects, for example, <code class="docutils literal notranslate"><span class="pre">list.format</span></code>
would be specified as <code class="docutils literal notranslate"><span class="pre">{"list":</span> <span class="pre">{"format":</span> <span class="pre">"table"}}</span></code>.</p>
</section>
<section id="shebang-lines">
<span id="pymanager-shebang"></span><h3><span class="section-number">4.1.9. </span>Shebang lines<a class="headerlink" href="#shebang-lines" title="Link to this heading">¶</a></h3>
<p>If the first line of a script file starts with <code class="docutils literal notranslate"><span class="pre">#!</span></code>, it is known as a
"shebang" line. Linux and other Unix like operating systems have native
support for such lines and they are commonly used on such systems to indicate
how a script should be executed. The <code class="docutils literal notranslate"><span class="pre">python</span></code> and <code class="docutils literal notranslate"><span class="pre">py</span></code> commands allow the
same facilities to be used with Python scripts on Windows.</p>
<p>To allow shebang lines in Python scripts to be portable between Unix and
Windows, a number of 'virtual' commands are supported to specify which
interpreter to use. The supported virtual commands are:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">/usr/bin/env</span> <span class="pre"><ALIAS></span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/usr/bin/env</span> <span class="pre">-S</span> <span class="pre"><ALIAS></span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/usr/bin/<ALIAS></span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/usr/local/bin/<ALIAS></span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre"><ALIAS></span></code></p></li>
</ul>
<p>For example, if the first line of your script starts with</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="ch">#! /usr/bin/python</span>
</pre></div>
</div>
<p>The default Python or an active virtual environment will be located and used.
As many Python scripts written to work on Unix will already have this line,
you should find these scripts can be used by the launcher without modification.
If you are writing a new script on Windows which you hope will be useful on
Unix, you should use one of the shebang lines starting with <code class="docutils literal notranslate"><span class="pre">/usr</span></code>.</p>
<p>Any of the above virtual commands can have <code class="docutils literal notranslate"><span class="pre"><ALIAS></span></code> replaced by an alias from
an installed runtime. That is, any command generated in the global aliases
directory (which you may have added to your <span class="target" id="index-6"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> environment variable)
can be used in a shebang, even if it is not on your <span class="target" id="index-7"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>. This allows
the use of shebangs like <code class="docutils literal notranslate"><span class="pre">/usr/bin/python3.12</span></code> to select a particular runtime.</p>
<p>If no runtimes are installed, or if automatic installation is enabled, the
requested runtime will be installed if necessary. See <a class="reference internal" href="#pymanager-config"><span class="std std-ref">Configuration</span></a>
for information about configuration settings.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">/usr/bin/env</span></code> form of shebang line will also search the <span class="target" id="index-8"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>
environment variable for unrecognized commands. This corresponds to the
behaviour of the Unix <code class="docutils literal notranslate"><span class="pre">env</span></code> program, which performs the same search, but
prefers launching known Python commands. A warning may be displayed when
searching for arbitrary executables, and this search may be disabled by the
<code class="docutils literal notranslate"><span class="pre">shebang_can_run_anything</span></code> configuration option.</p>
<p>Shebang lines that do not match any of patterns are treated as <em>Windows</em>
executable paths that are absolute or relative to the directory containing the
script file. This is a convenience for Windows-only scripts, such as those
generated by an installer, since the behavior is not compatible with Unix-style
shells. These paths may be quoted, and may include multiple arguments, after
which the path to the script and any additional arguments will be appended.
This functionality may be disabled by the <code class="docutils literal notranslate"><span class="pre">shebang_can_run_anything</span></code>
configuration option.</p>
<p>Since version 26.3 of the Python install manager, custom shebang templates may
be added to your configuration file. Add the <code class="docutils literal notranslate"><span class="pre">shebang_templates</span></code> object with
one member for each template (the string to match) and the command to use when
the template is matched. Most commands should be <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-V:<tag></span></code> (or <code class="docutils literal notranslate"><span class="pre">pyw</span></code>) to
launch one of your installed runtimes. The <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3.<version></span></code> form is also
allowed, as is a plain <code class="docutils literal notranslate"><span class="pre">py</span></code> to launch the default. No other arguments are
supported.</p>
<div class="highlight-json5 notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="w"> </span><span class="nv">"shebang_templates"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nv">"/usr/bin/python"</span><span class="p">:</span><span class="w"> </span><span class="s">"py"</span><span class="p">,</span>
<span class="w"> </span><span class="nv">"/usr/bin/my_custom_python"</span><span class="p">:</span><span class="w"> </span><span class="s">"py -V:MyCustomPython/3"</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>If the substitute command is not <code class="docutils literal notranslate"><span class="pre">py</span></code> or <code class="docutils literal notranslate"><span class="pre">pyw</span></code>, it will be written back into
the shebang and regular handling continues. If launching arbitrary executables
is permitted, then providing a full path will allow you to redirect from Python
to any executable. The template should match either the entire line (ignoring
leading and trailing whitespace), or up to the first space in the shebang line.</p>
<div class="admonition note">
<p class="admonition-title">توجه</p>
<p>The behaviour of shebangs in the Python install manager is subtly different
from the previous <code class="docutils literal notranslate"><span class="pre">py.exe</span></code> launcher, and the old configuration options no
longer apply. If you are specifically reliant on the old behaviour or
configuration, we recommend installing the <a class="reference external" href="https://www.python.org/ftp/python/3.14.0/win32/launcher.msi">legacy launcher</a>. The legacy
launcher's <code class="docutils literal notranslate"><span class="pre">py</span></code> command will override PyManager's one by default, and you
will need to use <code class="docutils literal notranslate"><span class="pre">pymanager</span></code> commands for installing and uninstalling.</p>
</div>
</section>
<section id="advanced-installation">
<span id="pymanager-advancedinstall"></span><h3><span class="section-number">4.1.10. </span>Advanced installation<a class="headerlink" href="#advanced-installation" title="Link to this heading">¶</a></h3>
<p>For situations where an MSIX cannot be installed, such as some older
administrative distribution platforms, there is an MSI available from the
python.org downloads page. This MSI has no user interface, and can only perform
per-machine installs to its default location in Program Files. It will attempt
to modify the system <span class="target" id="index-9"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> environment variable to include this install
location, but be sure to validate this on your configuration.</p>
<div class="admonition note">
<p class="admonition-title">توجه</p>
<p>Windows Server 2019 is the only version of Windows that CPython supports that
does not support MSIX. For Windows Server 2019, you should use the MSI.</p>
</div>
<p>Be aware that the MSI package does not bundle any runtimes, and so is not
suitable for installs into offline environments without also creating an offline
install index. See <a class="reference internal" href="#pymanager-offline"><span class="std std-ref">Offline installs</span></a> and <a class="reference internal" href="#pymanager-admin-config"><span class="std std-ref">Administrative configuration</span></a>
for information on handling these scenarios.</p>
<p>Runtimes installed by the MSI are shared with those installed by the MSIX, and
are all per-user only. The Python install manager does not support installing
runtimes per-machine. To emulate a per-machine install, you can use <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">install</span>
<span class="pre">--target=<shared</span> <span class="pre">location></span></code> as administrator and add your own system-wide
modifications to <span class="target" id="index-10"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>, the registry, or the Start menu.</p>
<p>When the MSIX is installed, but commands are not available in the <span class="target" id="index-11"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>
environment variable, they can be found under
<code class="file docutils literal notranslate"><span class="pre">%LocalAppData%\Microsoft\WindowsApps\PythonSoftwareFoundation.PythonManager_3847v3x7pw1km</span></code>
or
<code class="file docutils literal notranslate"><span class="pre">%LocalAppData%\Microsoft\WindowsApps\PythonSoftwareFoundation.PythonManager_qbz5n2kfra8p0</span></code>,
depending on whether it was installed from python.org or through the Windows
Store. Attempting to run the executable directly from Program Files is not
recommended.</p>
<p>To programmatically install the Python install manager, it is easiest to use
WinGet, which is included with all supported versions of Windows:</p>
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="p">$></span> <span class="n">winget</span> <span class="n">install</span> <span class="n">9NQ7512CXL7T</span> <span class="n">-e</span> <span class="p">-</span><span class="n">-accept-package-agreements</span> <span class="p">-</span><span class="n">-disable-interactivity</span>
<span class="c"># Optionally run the configuration checker and accept all changes</span>
<span class="p">$></span> <span class="n">py</span> <span class="n">install</span> <span class="p">-</span><span class="n">-configure</span> <span class="n">-y</span>
</pre></div>
</div>
<p>To download the Python install manager and install on another machine, the
following WinGet command will download the required files from the Store to your
Downloads directory (add <code class="docutils literal notranslate"><span class="pre">-d</span> <span class="pre"><location></span></code> to customize the output location).
This also generates a YAML file that appears to be unnecessary, as the
downloaded MSIX can be installed by launching or using the commands below.</p>
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="p">$></span> <span class="n">winget</span> <span class="n">download</span> <span class="n">9NQ7512CXL7T</span> <span class="n">-e</span> <span class="p">-</span><span class="n">-skip-license</span> <span class="p">-</span><span class="n">-accept-package-agreements</span> <span class="p">-</span><span class="n">-accept-source-agreements</span>
</pre></div>
</div>
<p>To programmatically install or uninstall an MSIX using only PowerShell, the
<a class="reference external" href="https://learn.microsoft.com/powershell/module/appx/add-appxpackage">Add-AppxPackage</a> and <a class="reference external" href="https://learn.microsoft.com/powershell/module/appx/remove-appxpackage">Remove-AppxPackage</a> PowerShell cmdlets are recommended:</p>
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="p">$></span> <span class="nb">Add-AppxPackage</span> <span class="n">C</span><span class="p">:\</span><span class="n">Downloads</span><span class="p">\</span><span class="n">python-manager</span><span class="p">-</span><span class="n">25</span><span class="p">.</span><span class="n">0</span><span class="p">.</span><span class="n">msix</span>
<span class="p">...</span>
<span class="p">$></span> <span class="nb">Get-AppxPackage</span> <span class="n">PythonSoftwareFoundation</span><span class="p">.</span><span class="n">PythonManager</span> <span class="p">|</span> <span class="nb">Remove-AppxPackage</span>
</pre></div>
</div>
<p>The latest release can be downloaded and installed by Windows by passing the
AppInstaller file to the Add-AppxPackage command. This installs using the MSIX
on python.org, and is only recommended for cases where installing via the Store
(interactively or using WinGet) is not possible.</p>
<div class="highlight-powershell notranslate"><div class="highlight"><pre><span></span><span class="p">$></span> <span class="nb">Add-AppxPackage</span> <span class="n">-AppInstallerFile</span> <span class="n">https</span><span class="p">://</span><span class="n">www</span><span class="p">.</span><span class="n">python</span><span class="p">.</span><span class="n">org</span><span class="p">/</span><span class="n">ftp</span><span class="p">/</span><span class="n">python</span><span class="p">/</span><span class="n">pymanager</span><span class="p">/</span><span class="n">pymanager</span><span class="p">.</span><span class="n">appinstaller</span>
</pre></div>
</div>
<p>Other tools and APIs may also be used to provision an MSIX package for all users
on a machine, but Python does not consider this a supported scenario. We suggest
looking into the PowerShell <a class="reference external" href="https://learn.microsoft.com/powershell/module/dism/add-appxprovisionedpackage">Add-AppxProvisionedPackage</a> cmdlet, the native
Windows <a class="reference external" href="https://learn.microsoft.com/uwp/api/windows.management.deployment.packagemanager">PackageManager</a> class, or the documentation and support for your
deployment tool.</p>
<p>Regardless of the install method, users will still need to install their own
copies of Python itself, as there is no way to trigger those installs without
being a logged in user. When using the MSIX, the latest version of Python will
be available for all users to install without network access.</p>
<p>Note that the MSIX downloadable from the Store and from the Python website are
subtly different and cannot be installed at the same time. Wherever possible,
we suggest using the above WinGet commands to download the package from the
Store to reduce the risk of setting up conflicting installs. There are no
licensing restrictions on the Python install manager that would prevent using
the Store package in this way.</p>
</section>
<section id="administrative-configuration">
<span id="pymanager-admin-config"></span><h3><span class="section-number">4.1.11. </span>Administrative configuration<a class="headerlink" href="#administrative-configuration" title="Link to this heading">¶</a></h3>
<p>There are a number of options that may be useful for administrators to override
configuration of the Python install manager. These can be used to provide local
caching, disable certain shortcut types, override bundled content. All of the
above configuration options may be set, as well as those below.</p>
<p>Configuration options may be overridden in the registry by setting values under
<code class="file docutils literal notranslate"><span class="pre">HKEY_LOCAL_MACHINE\Software\Policies\Python\PyManager</span></code>, where the
value name matches the configuration key and the value type is <code class="docutils literal notranslate"><span class="pre">REG_SZ</span></code>. Note
that this key can itself be customized, but only by modifying the core config
file distributed with the Python install manager. We recommend, however, that
registry values are used only to set <code class="docutils literal notranslate"><span class="pre">base_config</span></code> to a JSON file containing
the full set of overrides. Registry key overrides will replace any other
configured setting, while <code class="docutils literal notranslate"><span class="pre">base_config</span></code> allows users to further modify
settings they may need.</p>
<p>Note that most settings with environment variables support those variables
because their default setting specifies the variable. If you override them, the
environment variable will no longer work, unless you override it with another
one. For example, the default value of <code class="docutils literal notranslate"><span class="pre">confirm</span></code> is literally
<code class="docutils literal notranslate"><span class="pre">%PYTHON_MANAGER_CONFIRM%</span></code>, which will resolve the variable at load time. If
you override the value to <code class="docutils literal notranslate"><span class="pre">yes</span></code>, then the environment variable will no longer
be used. If you override the value to <code class="docutils literal notranslate"><span class="pre">%CONFIRM%</span></code>, then that environment
variable will be used instead.</p>
<p>Configuration settings that are paths are interpreted as relative to the
directory containing the configuration file that specified them.</p>
<p class="rubric">Administrative configuration options</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Config Key</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">base_config</span></code></p></td>
<td><p>The highest priority configuration file to read.
Note that only the built-in configuration file and the registry can
modify this setting.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">user_config</span></code></p></td>
<td><p>The second configuration file to read.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">additional_config</span></code></p></td>
<td><p>The third configuration file to read.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">registry_override_key</span></code></p></td>
<td><p>Registry location to check for overrides.
Note that only the built-in configuration file can modify this setting.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">bundled_dir</span></code></p></td>
<td><p>Read-only directory containing locally cached files.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">install.fallback_source</span></code></p></td>
<td><p>Path or URL to an index to consult when the main index cannot be accessed.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">install.enable_shortcut_kinds</span></code></p></td>
<td><p>Comma-separated list of shortcut kinds to allow (e.g. <code class="docutils literal notranslate"><span class="pre">"pep514,start"</span></code>).
Enabled shortcuts may still be disabled by <code class="docutils literal notranslate"><span class="pre">disable_shortcut_kinds</span></code>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">install.disable_shortcut_kinds</span></code></p></td>
<td><p>Comma-separated list of shortcut kinds to exclude
(e.g. <code class="docutils literal notranslate"><span class="pre">"pep514,start"</span></code>).
Disabled shortcuts are not reactivated by <code class="docutils literal notranslate"><span class="pre">enable_shortcut_kinds</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">install.hard_link_entrypoints</span></code></p></td>
<td><p>True to use hard links for global shortcuts to save disk space. If false,
each shortcut executable is copied instead. After changing this setting,
you must run <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">install</span> <span class="pre">--refresh</span> <span class="pre">--force</span></code> to update existing
commands.
By default, true. Disabling this may be necessary for troubleshooting or
systems that have issues with file links.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">pep514_root</span></code></p></td>
<td><p>Registry location to read and write PEP 514 entries into.
By default, <code class="file docutils literal notranslate"><span class="pre">HKEY_CURRENT_USER\Software\Python</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">start_folder</span></code></p></td>
<td><p>Start menu folder to write shortcuts into.
By default, <code class="docutils literal notranslate"><span class="pre">Python</span></code>.
This path is relative to the user's Programs folder.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">virtual_env</span></code></p></td>
<td><p>Path to the active virtual environment.
By default, this is <code class="docutils literal notranslate"><span class="pre">%VIRTUAL_ENV%</span></code>, but may be set empty
to disable venv detection.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">shebang_can_run_anything_silently</span></code></p></td>
<td><p>True to suppress visible warnings when a shebang launches an application
other than a Python runtime.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">source_settings</span></code></p></td>
<td><p>A mapping from source URL to settings specific to that index.
When multiple configuration files include this section, URL settings are
added or overwritten, but individual settings are not merged.
These settings are currently only for <a class="reference internal" href="#pymanager-index-signatures"><span class="std std-ref">index signatures</span></a>.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="installing-free-threaded-binaries">
<span id="install-freethreaded-windows"></span><h3><span class="section-number">4.1.12. </span>Installing free-threaded binaries<a class="headerlink" href="#installing-free-threaded-binaries" title="Link to this heading">¶</a></h3>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
<p>Pre-built distributions of the free-threaded build are available
by installing tags with the <code class="docutils literal notranslate"><span class="pre">t</span></code> suffix.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$> py install 3.14t
$> py install 3.14t-arm64
$> py install 3.14t-32
</pre></div>
</div>
<p>This will install and register as normal. If you have no other runtimes
installed, then <code class="docutils literal notranslate"><span class="pre">python</span></code> will launch this one. Otherwise, you will need to use
<code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-V:3.14t</span> <span class="pre">...</span></code> or, if you have added the global aliases directory to your
<span class="target" id="index-12"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> environment variable, the <code class="docutils literal notranslate"><span class="pre">python3.14t.exe</span></code> commands.</p>
</section>
<section id="index-signatures">
<span id="pymanager-index-signatures"></span><h3><span class="section-number">4.1.13. </span>Index signatures<a class="headerlink" href="#index-signatures" title="Link to this heading">¶</a></h3>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 26.2.</span></p>
</div>
<p>Index files may be signed to detect tampering. A signature is a catalog file
at the same URL as the index with <code class="docutils literal notranslate"><span class="pre">.cat</span></code> added to the filename. The catalog
file should contain the hash of its matching index file, and should be signed
with a valid Authenticode signature. This allows standard tooling (on Windows)
to generate a signature, and any certificate may be used as long as the client
operating system already trusts its certification authority (root CA).</p>
<p>Index signatures are only downloaded and checked when the local configuration's
<code class="docutils literal notranslate"><span class="pre">source_settings</span></code> section includes the index URL and <code class="docutils literal notranslate"><span class="pre">requires_signature</span></code> is
true, or the index JSON contains <code class="docutils literal notranslate"><span class="pre">requires_signature</span></code> set to true. When the
setting exists in local configuration, even when false, settings in the index
are ignored.</p>
<p>As well as requiring a valid signature, the <code class="docutils literal notranslate"><span class="pre">required_root_subject</span></code> and
<code class="docutils literal notranslate"><span class="pre">required_publisher_subject</span></code> settings can further restrict acceptable
signatures based on the certificate Subject fields. Any attribute specified in
the configuration must match the attribute in the certificate (additional
attributes in the certificate are ignored). Typical attributes are <code class="docutils literal notranslate"><span class="pre">CN=</span></code> for
the common name, <code class="docutils literal notranslate"><span class="pre">O=</span></code> for the organizational unit, and <code class="docutils literal notranslate"><span class="pre">C=</span></code> for the
publisher's country.</p>
<p>Finally, the <code class="docutils literal notranslate"><span class="pre">required_publisher_eku</span></code> setting allows requiring that a specific
Enhanced Key Usage (EKU) has been assigned to the publisher certificate. For