forked from python/python-docs-tr
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwindows.html
More file actions
1578 lines (1536 loc) · 113 KB
/
Copy pathwindows.html
File metadata and controls
1578 lines (1536 loc) · 113 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="tr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<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="https://docs.python.org/3/_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 property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>4. Using Python on Windows — Python 3.11.5 belgelendirmesi</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/translations.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Python 3.11.5 belgelendirmesi içinde ara"
href="../_static/opensearch.xml"/>
<link rel="author" title="Bu belgeler hakkında" href="../about.html" />
<link rel="index" title="Dizin" href="../genindex.html" />
<link rel="search" title="Ara" href="../search.html" />
<link rel="copyright" title="Telif Hakkı" href="../copyright.html" />
<link rel="next" title="5. Using Python on a Mac" 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>
</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="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="Hızlı Arama" aria-label="Hızlı Arama" type="search" name="q" />
<input type="submit" value="Git"/>
</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">İçindekiler</a></h3>
<ul>
<li><a class="reference internal" href="#">4. Using Python on Windows</a><ul>
<li><a class="reference internal" href="#the-full-installer">4.1. The full installer</a><ul>
<li><a class="reference internal" href="#installation-steps">4.1.1. Installation steps</a></li>
<li><a class="reference internal" href="#removing-the-max-path-limitation">4.1.2. Removing the MAX_PATH Limitation</a></li>
<li><a class="reference internal" href="#installing-without-ui">4.1.3. Installing Without UI</a></li>
<li><a class="reference internal" href="#installing-without-downloading">4.1.4. Installing Without Downloading</a></li>
<li><a class="reference internal" href="#modifying-an-install">4.1.5. Modifying an install</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-microsoft-store-package">4.2. The Microsoft Store package</a><ul>
<li><a class="reference internal" href="#known-issues">4.2.1. Known issues</a><ul>
<li><a class="reference internal" href="#redirection-of-local-data-registry-and-temporary-paths">4.2.1.1. Redirection of local data, registry, and temporary paths</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#the-nuget-org-packages">4.3. The nuget.org packages</a></li>
<li><a class="reference internal" href="#the-embeddable-package">4.4. The embeddable package</a><ul>
<li><a class="reference internal" href="#python-application">4.4.1. Python Application</a></li>
<li><a class="reference internal" href="#embedding-python">4.4.2. Embedding Python</a></li>
</ul>
</li>
<li><a class="reference internal" href="#alternative-bundles">4.5. Alternative bundles</a></li>
<li><a class="reference internal" href="#configuring-python">4.6. Configuring Python</a><ul>
<li><a class="reference internal" href="#excursus-setting-environment-variables">4.6.1. Excursus: Setting environment variables</a></li>
<li><a class="reference internal" href="#finding-the-python-executable">4.6.2. Finding the Python executable</a></li>
</ul>
</li>
<li><a class="reference internal" href="#utf-8-mode">4.7. UTF-8 mode</a></li>
<li><a class="reference internal" href="#python-launcher-for-windows">4.8. Python Launcher for Windows</a><ul>
<li><a class="reference internal" href="#getting-started">4.8.1. Getting started</a><ul>
<li><a class="reference internal" href="#from-the-command-line">4.8.1.1. From the command-line</a></li>
<li><a class="reference internal" href="#virtual-environments">4.8.1.2. Virtual environments</a></li>
<li><a class="reference internal" href="#from-a-script">4.8.1.3. From a script</a></li>
<li><a class="reference internal" href="#from-file-associations">4.8.1.4. From file associations</a></li>
</ul>
</li>
<li><a class="reference internal" href="#shebang-lines">4.8.2. Shebang Lines</a></li>
<li><a class="reference internal" href="#arguments-in-shebang-lines">4.8.3. Arguments in shebang lines</a></li>
<li><a class="reference internal" href="#customization">4.8.4. Customization</a><ul>
<li><a class="reference internal" href="#customization-via-ini-files">4.8.4.1. Customization via INI files</a></li>
<li><a class="reference internal" href="#customizing-default-python-versions">4.8.4.2. Customizing default Python versions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#diagnostics">4.8.5. Diagnostics</a></li>
<li><a class="reference internal" href="#dry-run">4.8.6. Dry Run</a></li>
<li><a class="reference internal" href="#install-on-demand">4.8.7. Install on demand</a></li>
<li><a class="reference internal" href="#return-codes">4.8.8. Return codes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#finding-modules">4.9. Finding modules</a></li>
<li><a class="reference internal" href="#additional-modules">4.10. Additional modules</a><ul>
<li><a class="reference internal" href="#pywin32">4.10.1. PyWin32</a></li>
<li><a class="reference internal" href="#cx-freeze">4.10.2. cx_Freeze</a></li>
</ul>
</li>
<li><a class="reference internal" href="#compiling-python-on-windows">4.11. Compiling Python on Windows</a></li>
<li><a class="reference internal" href="#other-platforms">4.12. Other Platforms</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Önceki konu</h4>
<p class="topless"><a href="configure.html"
title="önceki bölüm"><span class="section-number">3. </span>Configure Python</a></p>
</div>
<div>
<h4>Sonraki konu</h4>
<p class="topless"><a href="mac.html"
title="sonraki bölüm"><span class="section-number">5. </span>Using Python on a Mac</a></p>
</div>
<div role="note" aria-label="source link">
<h3>Bu Sayfa</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Hata Bildir</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.11/Doc/using/windows.rst"
rel="nofollow">Kaynağı Göster
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Gezinti</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="Genel Endeks"
accesskey="I">dizin</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Modül Dizini"
>modülleri</a> |</li>
<li class="right" >
<a href="mac.html" title="5. Using Python on a Mac"
accesskey="N">sonraki</a> |</li>
<li class="right" >
<a href="configure.html" title="3. Configure Python"
accesskey="P">önceki</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.11.5 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="Hızlı Arama" aria-label="Hızlı Arama" type="search" name="q" id="search-box" />
<input type="submit" value="Git" />
</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="Permalink 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. To make Python available, the CPython team
has compiled Windows installers (MSI packages) with every <a class="reference external" href="https://www.python.org/download/releases/">release</a> for many years. These installers
are primarily intended to add a per-user installation of Python, with the
core interpreter and library being used by a single user. The installer is also
able to install for all users of a single machine, and a separate ZIP file is
available for application-local distributions.</p>
<p>As specified in <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0011/"><strong>PEP 11</strong></a>, a Python release only supports a Windows platform
while Microsoft considers the platform under extended support. This means that
Python 3.11 supports Windows 8.1 and newer. If you require Windows 7
support, please install Python 3.8.</p>
<p>There are a number of different installers available for Windows, each with
certain benefits and downsides.</p>
<p><a class="reference internal" href="#windows-full"><span class="std std-ref">The full installer</span></a> contains all components and is the best option for
developers using Python for any kind of project.</p>
<p><a class="reference internal" href="#windows-store"><span class="std std-ref">The Microsoft Store package</span></a> is a simple installation of Python that is suitable for
running scripts and packages, and using IDLE or other development environments.
It requires Windows 10 and above, but can be safely installed without corrupting other
programs. It also provides many convenient commands for launching Python and
its tools.</p>
<p><a class="reference internal" href="#windows-nuget"><span class="std std-ref">The nuget.org packages</span></a> are lightweight installations intended for continuous
integration systems. It can be used to build Python packages or run scripts,
but is not updateable and has no user interface tools.</p>
<p><a class="reference internal" href="#windows-embeddable"><span class="std std-ref">The embeddable package</span></a> is a minimal package of Python suitable for
embedding into a larger application.</p>
<section id="the-full-installer">
<span id="windows-full"></span><h2><span class="section-number">4.1. </span>The full installer<a class="headerlink" href="#the-full-installer" title="Permalink to this heading">¶</a></h2>
<section id="installation-steps">
<h3><span class="section-number">4.1.1. </span>Installation steps<a class="headerlink" href="#installation-steps" title="Permalink to this heading">¶</a></h3>
<p>Four Python 3.11 installers are available for download - two each for the
32-bit and 64-bit versions of the interpreter. The <em>web installer</em> is a small
initial download, and it will automatically download the required components as
necessary. The <em>offline installer</em> includes the components necessary for a
default installation and only requires an internet connection for optional
features. See <a class="reference internal" href="#install-layout-option"><span class="std std-ref">Installing Without Downloading</span></a> for other ways to avoid downloading
during installation.</p>
<p>After starting the installer, one of two options may be selected:</p>
<img alt="../_images/win_installer.png" src="../_images/win_installer.png" />
<p>If you select “Install Now”:</p>
<ul class="simple">
<li><p>You will <em>not</em> need to be an administrator (unless a system update for the
C Runtime Library is required or you install the <a class="reference internal" href="#launcher"><span class="std std-ref">Python Launcher for Windows</span></a> for all
users)</p></li>
<li><p>Python will be installed into your user directory</p></li>
<li><p>The <a class="reference internal" href="#launcher"><span class="std std-ref">Python Launcher for Windows</span></a> will be installed according to the option at the bottom
of the first page</p></li>
<li><p>The standard library, test suite, launcher and pip will be installed</p></li>
<li><p>If selected, the install directory will be added to your <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code></p></li>
<li><p>Shortcuts will only be visible for the current user</p></li>
</ul>
<p>Selecting “Customize installation” will allow you to select the features to
install, the installation location and other options or post-install actions.
To install debugging symbols or binaries, you will need to use this option.</p>
<p>To perform an all-users installation, you should select “Customize
installation”. In this case:</p>
<ul class="simple">
<li><p>You may be required to provide administrative credentials or approval</p></li>
<li><p>Python will be installed into the Program Files directory</p></li>
<li><p>The <a class="reference internal" href="#launcher"><span class="std std-ref">Python Launcher for Windows</span></a> will be installed into the Windows directory</p></li>
<li><p>Optional features may be selected during installation</p></li>
<li><p>The standard library can be pre-compiled to bytecode</p></li>
<li><p>If selected, the install directory will be added to the system <span class="target" id="index-2"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code></p></li>
<li><p>Shortcuts are available for all users</p></li>
</ul>
</section>
<section id="removing-the-max-path-limitation">
<span id="max-path"></span><h3><span class="section-number">4.1.2. </span>Removing the MAX_PATH Limitation<a class="headerlink" href="#removing-the-max-path-limitation" title="Permalink to this heading">¶</a></h3>
<p>Windows historically has limited path lengths to 260 characters. This meant that
paths longer than this would not resolve and errors would result.</p>
<p>In the latest versions of Windows, this limitation can be expanded to
approximately 32,000 characters. Your administrator will need to activate the
“Enable Win32 long paths” group policy, or set <code class="docutils literal notranslate"><span class="pre">LongPathsEnabled</span></code> to <code class="docutils literal notranslate"><span class="pre">1</span></code>
in the registry key
<code class="docutils literal notranslate"><span class="pre">HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem</span></code>.</p>
<p>This allows the <a class="reference internal" href="../library/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> function, the <a class="reference internal" href="../library/os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a> module and most other
path functionality to accept and return paths longer than 260 characters.</p>
<p>After changing the above option, no further configuration is required.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">3.6 sürümünde değişti: </span>Support for long paths was enabled in Python.</p>
</div>
</section>
<section id="installing-without-ui">
<span id="install-quiet-option"></span><h3><span class="section-number">4.1.3. </span>Installing Without UI<a class="headerlink" href="#installing-without-ui" title="Permalink to this heading">¶</a></h3>
<p>All of the options available in the installer UI can also be specified from the
command line, allowing scripted installers to replicate an installation on many
machines without user interaction. These options may also be set without
suppressing the UI in order to change some of the defaults.</p>
<p>To completely hide the installer UI and install Python silently, pass the
<code class="docutils literal notranslate"><span class="pre">/quiet</span></code> option. To skip past the user interaction but still display
progress and errors, pass the <code class="docutils literal notranslate"><span class="pre">/passive</span></code> option. The <code class="docutils literal notranslate"><span class="pre">/uninstall</span></code>
option may be passed to immediately begin removing Python - no confirmation
prompt will be displayed.</p>
<p>All other options are passed as <code class="docutils literal notranslate"><span class="pre">name=value</span></code>, where the value is usually
<code class="docutils literal notranslate"><span class="pre">0</span></code> to disable a feature, <code class="docutils literal notranslate"><span class="pre">1</span></code> to enable a feature, or a path. The full list
of available options is shown below.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Default</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>InstallAllUsers</p></td>
<td><p>Perform a system-wide installation.</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p>TargetDir</p></td>
<td><p>The installation directory</p></td>
<td><p>Selected based on
InstallAllUsers</p></td>
</tr>
<tr class="row-even"><td><p>DefaultAllUsersTargetDir</p></td>
<td><p>The default installation directory
for all-user installs</p></td>
<td><p><code class="file docutils literal notranslate"><span class="pre">%ProgramFiles%\Python</span> <span class="pre">X.Y</span></code> or <code class="file docutils literal notranslate"><span class="pre">%ProgramFiles(x86)%\Python</span> <span class="pre">X.Y</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>DefaultJustForMeTargetDir</p></td>
<td><p>The default install directory for
just-for-me installs</p></td>
<td><p><code class="file docutils literal notranslate"><span class="pre">%LocalAppData%\Programs\Python\PythonXY</span></code> or
<code class="file docutils literal notranslate"><span class="pre">%LocalAppData%\Programs\Python\PythonXY-32</span></code> or
<code class="file docutils literal notranslate"><span class="pre">%LocalAppData%\Programs\Python\PythonXY-64</span></code></p></td>
</tr>
<tr class="row-even"><td><p>DefaultCustomTargetDir</p></td>
<td><p>The default custom install directory
displayed in the UI</p></td>
<td><p>(empty)</p></td>
</tr>
<tr class="row-odd"><td><p>AssociateFiles</p></td>
<td><p>Create file associations if the
launcher is also installed.</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>CompileAll</p></td>
<td><p>Compile all <code class="docutils literal notranslate"><span class="pre">.py</span></code> files to
<code class="docutils literal notranslate"><span class="pre">.pyc</span></code>.</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p>PrependPath</p></td>
<td><p>Prepend install and Scripts
directories to <span class="target" id="index-3"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> and
add <code class="docutils literal notranslate"><span class="pre">.PY</span></code> to <span class="target" id="index-4"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATHEXT</span></code></p></td>
<td><p>0</p></td>
</tr>
<tr class="row-even"><td><p>AppendPath</p></td>
<td><p>Append install and Scripts
directories to <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> and
add <code class="docutils literal notranslate"><span class="pre">.PY</span></code> to <span class="target" id="index-6"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATHEXT</span></code></p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p>Shortcuts</p></td>
<td><p>Create shortcuts for the interpreter,
documentation and IDLE if installed.</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>Include_doc</p></td>
<td><p>Install Python manual</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>Include_debug</p></td>
<td><p>Install debug binaries</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-even"><td><p>Include_dev</p></td>
<td><p>Install developer headers and
libraries. Omitting this may lead to
an unusable installation.</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>Include_exe</p></td>
<td><p>Install <code class="file docutils literal notranslate"><span class="pre">python.exe</span></code> and
related files. Omitting this may
lead to an unusable installation.</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>Include_launcher</p></td>
<td><p>Install <a class="reference internal" href="#launcher"><span class="std std-ref">Python Launcher for Windows</span></a>.</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>InstallLauncherAllUsers</p></td>
<td><p>Installs the launcher for all
users. Also requires
<code class="docutils literal notranslate"><span class="pre">Include_launcher</span></code> to be set to 1</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>Include_lib</p></td>
<td><p>Install standard library and
extension modules. Omitting this may
lead to an unusable installation.</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>Include_pip</p></td>
<td><p>Install bundled pip and setuptools</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>Include_symbols</p></td>
<td><p>Install debugging symbols (<code class="docutils literal notranslate"><span class="pre">*.pdb</span></code>)</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p>Include_tcltk</p></td>
<td><p>Install Tcl/Tk support and IDLE</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>Include_test</p></td>
<td><p>Install standard library test suite</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-odd"><td><p>Include_tools</p></td>
<td><p>Install utility scripts</p></td>
<td><p>1</p></td>
</tr>
<tr class="row-even"><td><p>LauncherOnly</p></td>
<td><p>Only installs the launcher. This
will override most other options.</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-odd"><td><p>SimpleInstall</p></td>
<td><p>Disable most install UI</p></td>
<td><p>0</p></td>
</tr>
<tr class="row-even"><td><p>SimpleInstallDescription</p></td>
<td><p>A custom message to display when the
simplified install UI is used.</p></td>
<td><p>(empty)</p></td>
</tr>
</tbody>
</table>
<p>For example, to silently install a default, system-wide Python installation,
you could use the following command (from an elevated command prompt):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
</pre></div>
</div>
<p>To allow users to easily install a personal copy of Python without the test
suite, you could provide a shortcut with the following command. This will
display a simplified initial page and disallow customization:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python-3.9.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0
SimpleInstall=1 SimpleInstallDescription="Just for me, no test suite."
</pre></div>
</div>
<p>(Note that omitting the launcher also omits file associations, and is only
recommended for per-user installs when there is also a system-wide installation
that included the launcher.)</p>
<p>The options listed above can also be provided in a file named <code class="docutils literal notranslate"><span class="pre">unattend.xml</span></code>
alongside the executable. This file specifies a list of options and values.
When a value is provided as an attribute, it will be converted to a number if
possible. Values provided as element text are always left as strings. This
example file sets the same options as the previous example:</p>
<div class="highlight-xml notranslate"><div class="highlight"><pre><span></span><span class="nt"><Options></span>
<span class="w"> </span><span class="nt"><Option</span><span class="w"> </span><span class="na">Name=</span><span class="s">"InstallAllUsers"</span><span class="w"> </span><span class="na">Value=</span><span class="s">"no"</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"><Option</span><span class="w"> </span><span class="na">Name=</span><span class="s">"Include_launcher"</span><span class="w"> </span><span class="na">Value=</span><span class="s">"0"</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"><Option</span><span class="w"> </span><span class="na">Name=</span><span class="s">"Include_test"</span><span class="w"> </span><span class="na">Value=</span><span class="s">"no"</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"><Option</span><span class="w"> </span><span class="na">Name=</span><span class="s">"SimpleInstall"</span><span class="w"> </span><span class="na">Value=</span><span class="s">"yes"</span><span class="w"> </span><span class="nt">/></span>
<span class="w"> </span><span class="nt"><Option</span><span class="w"> </span><span class="na">Name=</span><span class="s">"SimpleInstallDescription"</span><span class="nt">></span>Just<span class="w"> </span>for<span class="w"> </span>me,<span class="w"> </span>no<span class="w"> </span>test<span class="w"> </span>suite<span class="nt"></Option></span>
<span class="nt"></Options></span>
</pre></div>
</div>
</section>
<section id="installing-without-downloading">
<span id="install-layout-option"></span><h3><span class="section-number">4.1.4. </span>Installing Without Downloading<a class="headerlink" href="#installing-without-downloading" title="Permalink to this heading">¶</a></h3>
<p>As some features of Python are not included in the initial installer download,
selecting those features may require an internet connection. To avoid this
need, all possible components may be downloaded on-demand to create a complete
<em>layout</em> that will no longer require an internet connection regardless of the
selected features. Note that this download may be bigger than required, but
where a large number of installations are going to be performed it is very
useful to have a locally cached copy.</p>
<p>Execute the following command from Command Prompt to download all possible
required files. Remember to substitute <code class="docutils literal notranslate"><span class="pre">python-3.9.0.exe</span></code> for the actual
name of your installer, and to create layouts in their own directories to
avoid collisions between files with the same name.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python-3.9.0.exe /layout [optional target directory]
</pre></div>
</div>
<p>You may also specify the <code class="docutils literal notranslate"><span class="pre">/quiet</span></code> option to hide the progress display.</p>
</section>
<section id="modifying-an-install">
<h3><span class="section-number">4.1.5. </span>Modifying an install<a class="headerlink" href="#modifying-an-install" title="Permalink to this heading">¶</a></h3>
<p>Once Python has been installed, you can add or remove features through the
Programs and Features tool that is part of Windows. Select the Python entry and
choose “Uninstall/Change” to open the installer in maintenance mode.</p>
<p>“Modify” allows you to add or remove features by modifying the checkboxes -
unchanged checkboxes will not install or remove anything. Some options cannot be
changed in this mode, such as the install directory; to modify these, you will
need to remove and then reinstall Python completely.</p>
<p>“Repair” will verify all the files that should be installed using the current
settings and replace any that have been removed or modified.</p>
<p>“Uninstall” will remove Python entirely, with the exception of the
<a class="reference internal" href="#launcher"><span class="std std-ref">Python Launcher for Windows</span></a>, which has its own entry in Programs and Features.</p>
</section>
</section>
<section id="the-microsoft-store-package">
<span id="windows-store"></span><h2><span class="section-number">4.2. </span>The Microsoft Store package<a class="headerlink" href="#the-microsoft-store-package" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">3.7.2 sürümünde geldi.</span></p>
</div>
<p>The Microsoft Store package is an easily installable Python interpreter that
is intended mainly for interactive use, for example, by students.</p>
<p>To install the package, ensure you have the latest Windows 10 updates and
search the Microsoft Store app for “Python 3.11”. Ensure that the app
you select is published by the Python Software Foundation, and install it.</p>
<div class="admonition warning">
<p class="admonition-title">Uyarı</p>
<p>Python will always be available for free on the Microsoft Store. If you
are asked to pay for it, you have not selected the correct package.</p>
</div>
<p>After installation, Python may be launched by finding it in Start.
Alternatively, it will be available from any Command Prompt or PowerShell
session by typing <code class="docutils literal notranslate"><span class="pre">python</span></code>. Further, pip and IDLE may be used by typing
<code class="docutils literal notranslate"><span class="pre">pip</span></code> or <code class="docutils literal notranslate"><span class="pre">idle</span></code>. IDLE can also be found in Start.</p>
<p>All three commands are also available with version number suffixes, for
example, as <code class="docutils literal notranslate"><span class="pre">python3.exe</span></code> and <code class="docutils literal notranslate"><span class="pre">python3.x.exe</span></code> as well as
<code class="docutils literal notranslate"><span class="pre">python.exe</span></code> (where <code class="docutils literal notranslate"><span class="pre">3.x</span></code> is the specific version you want to launch,
such as 3.11). Open “Manage App Execution Aliases” through Start to
select which version of Python is associated with each command. It is
recommended to make sure that <code class="docutils literal notranslate"><span class="pre">pip</span></code> and <code class="docutils literal notranslate"><span class="pre">idle</span></code> are consistent with
whichever version of <code class="docutils literal notranslate"><span class="pre">python</span></code> is selected.</p>
<p>Virtual environments can be created with <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">venv</span></code> and activated
and used as normal.</p>
<p>If you have installed another version of Python and added it to your
<code class="docutils literal notranslate"><span class="pre">PATH</span></code> variable, it will be available as <code class="docutils literal notranslate"><span class="pre">python.exe</span></code> rather than the
one from the Microsoft Store. To access the new installation, use
<code class="docutils literal notranslate"><span class="pre">python3.exe</span></code> or <code class="docutils literal notranslate"><span class="pre">python3.x.exe</span></code>.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">py.exe</span></code> launcher will detect this Python installation, but will prefer
installations from the traditional installer.</p>
<p>To remove Python, open Settings and use Apps and Features, or else find
Python in Start and right-click to select Uninstall. Uninstalling will
remove all packages you installed directly into this Python installation, but
will not remove any virtual environments</p>
<section id="known-issues">
<h3><span class="section-number">4.2.1. </span>Known issues<a class="headerlink" href="#known-issues" title="Permalink to this heading">¶</a></h3>
<section id="redirection-of-local-data-registry-and-temporary-paths">
<h4><span class="section-number">4.2.1.1. </span>Redirection of local data, registry, and temporary paths<a class="headerlink" href="#redirection-of-local-data-registry-and-temporary-paths" title="Permalink to this heading">¶</a></h4>
<p>Because of restrictions on Microsoft Store apps, Python scripts may not have
full write access to shared locations such as <span class="target" id="index-7"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TEMP</span></code> and the registry.
Instead, it will write to a private copy. If your scripts must modify the
shared locations, you will need to install the full installer.</p>
<p>At runtime, Python will use a private copy of well-known Windows folders and the registry.
For example, if the environment variable <span class="target" id="index-8"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">%APPDATA%</span></code> is <code class="file docutils literal notranslate"><span class="pre">c:\Users\<user>\AppData\</span></code>,
then when writing to <code class="file docutils literal notranslate"><span class="pre">C:\Users\<user>\AppData\Local</span></code> will write to
<code class="file docutils literal notranslate"><span class="pre">C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\</span></code>.</p>
<p>When reading files, Windows will return the file from the private folder, or if that does not exist, the
real Windows directory. For example reading <code class="file docutils literal notranslate"><span class="pre">C:\Windows\System32</span></code> returns the contents of <code class="file docutils literal notranslate"><span class="pre">C:\Windows\System32</span></code>
plus the contents of <code class="file docutils literal notranslate"><span class="pre">C:\Program</span> <span class="pre">Files\WindowsApps\package_name\VFS\SystemX86</span></code>.</p>
<p>You can find the real path of any existing file using <a class="reference internal" href="../library/os.path.html#os.path.realpath" title="os.path.realpath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.path.realpath()</span></code></a>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">os</span>
<span class="gp">>>> </span><span class="n">test_file</span> <span class="o">=</span> <span class="s1">'C:</span><span class="se">\\</span><span class="s1">Users</span><span class="se">\\</span><span class="s1">example</span><span class="se">\\</span><span class="s1">AppData</span><span class="se">\\</span><span class="s1">Local</span><span class="se">\\</span><span class="s1">test.txt'</span>
<span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">realpath</span><span class="p">(</span><span class="n">test_file</span><span class="p">)</span>
<span class="go">'C:\\Users\\example\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\test.txt'</span>
</pre></div>
</div>
<p>When writing to the Windows Registry, the following behaviors exist:</p>
<ul class="simple">
<li><p>Reading from <code class="docutils literal notranslate"><span class="pre">HKLM\\Software</span></code> is allowed and results are merged with the <code class="file docutils literal notranslate"><span class="pre">registry.dat</span></code> file in the package.</p></li>
<li><p>Writing to <code class="docutils literal notranslate"><span class="pre">HKLM\\Software</span></code> is not allowed if the corresponding key/value exists, i.e. modifying existing keys.</p></li>
<li><p>Writing to <code class="docutils literal notranslate"><span class="pre">HKLM\\Software</span></code> is allowed as long as a corresponding key/value does not exist in the package
and the user has the correct access permissions.</p></li>
</ul>
<p>For more detail on the technical basis for these limitations, please consult
Microsoft’s documentation on packaged full-trust apps, currently available at
<a class="reference external" href="https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes">docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes</a></p>
</section>
</section>
</section>
<section id="the-nuget-org-packages">
<span id="windows-nuget"></span><h2><span class="section-number">4.3. </span>The nuget.org packages<a class="headerlink" href="#the-nuget-org-packages" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">3.5.2 sürümünde geldi.</span></p>
</div>
<p>The nuget.org package is a reduced size Python environment intended for use on
continuous integration and build systems that do not have a system-wide
install of Python. While nuget is “the package manager for .NET”, it also works
perfectly fine for packages containing build-time tools.</p>
<p>Visit <a class="reference external" href="https://www.nuget.org/">nuget.org</a> for the most up-to-date information
on using nuget. What follows is a summary that is sufficient for Python
developers.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">nuget.exe</span></code> command line tool may be downloaded directly from
<code class="docutils literal notranslate"><span class="pre">https://aka.ms/nugetclidl</span></code>, for example, using curl or PowerShell. With the
tool, the latest version of Python for 64-bit or 32-bit machines is installed
using:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nuget.exe install python -ExcludeVersion -OutputDirectory .
nuget.exe install pythonx86 -ExcludeVersion -OutputDirectory .
</pre></div>
</div>
<p>To select a particular version, add a <code class="docutils literal notranslate"><span class="pre">-Version</span> <span class="pre">3.x.y</span></code>. The output directory
may be changed from <code class="docutils literal notranslate"><span class="pre">.</span></code>, and the package will be installed into a
subdirectory. By default, the subdirectory is named the same as the package,
and without the <code class="docutils literal notranslate"><span class="pre">-ExcludeVersion</span></code> option this name will include the specific
version installed. Inside the subdirectory is a <code class="docutils literal notranslate"><span class="pre">tools</span></code> directory that
contains the Python installation:</p>
<div class="highlight-doscon notranslate"><div class="highlight"><pre><span></span><span class="go"># Without -ExcludeVersion</span>
<span class="gp">></span> .\python.3.5.2\tools\python.exe -V
<span class="go">Python 3.5.2</span>
<span class="go"># With -ExcludeVersion</span>
<span class="gp">></span> .\python\tools\python.exe -V
<span class="go">Python 3.5.2</span>
</pre></div>
</div>
<p>In general, nuget packages are not upgradeable, and newer versions should be
installed side-by-side and referenced using the full path. Alternatively,
delete the package directory manually and install it again. Many CI systems
will do this automatically if they do not preserve files between builds.</p>
<p>Alongside the <code class="docutils literal notranslate"><span class="pre">tools</span></code> directory is a <code class="docutils literal notranslate"><span class="pre">build\native</span></code> directory. This
contains a MSBuild properties file <code class="docutils literal notranslate"><span class="pre">python.props</span></code> that can be used in a
C++ project to reference the Python install. Including the settings will
automatically use the headers and import libraries in your build.</p>
<p>The package information pages on nuget.org are
<a class="reference external" href="https://www.nuget.org/packages/python">www.nuget.org/packages/python</a>
for the 64-bit version and <a class="reference external" href="https://www.nuget.org/packages/pythonx86">www.nuget.org/packages/pythonx86</a> for the 32-bit version.</p>
</section>
<section id="the-embeddable-package">
<span id="windows-embeddable"></span><h2><span class="section-number">4.4. </span>The embeddable package<a class="headerlink" href="#the-embeddable-package" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">3.5 sürümünde geldi.</span></p>
</div>
<p>The embedded distribution is a ZIP file containing a minimal Python environment.
It is intended for acting as part of another application, rather than being
directly accessed by end-users.</p>
<p>When extracted, the embedded distribution is (almost) fully isolated from the
user’s system, including environment variables, system registry settings, and
installed packages. The standard library is included as pre-compiled and
optimized <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files in a ZIP, and <code class="docutils literal notranslate"><span class="pre">python3.dll</span></code>, <code class="docutils literal notranslate"><span class="pre">python37.dll</span></code>,
<code class="docutils literal notranslate"><span class="pre">python.exe</span></code> and <code class="docutils literal notranslate"><span class="pre">pythonw.exe</span></code> are all provided. Tcl/tk (including all
dependents, such as Idle), pip and the Python documentation are not included.</p>
<div class="admonition note">
<p class="admonition-title">Not</p>
<p>The embedded distribution does not include the <a class="reference external" href="https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist#visual-studio-2015-2017-2019-and-2022">Microsoft C Runtime</a> and it is
the responsibility of the application installer to provide this. The
runtime may have already been installed on a user’s system previously or
automatically via Windows Update, and can be detected by finding
<code class="docutils literal notranslate"><span class="pre">ucrtbase.dll</span></code> in the system directory.</p>
</div>
<p>Third-party packages should be installed by the application installer alongside
the embedded distribution. Using pip to manage dependencies as for a regular
Python installation is not supported with this distribution, though with some
care it may be possible to include and use pip for automatic updates. In
general, third-party packages should be treated as part of the application
(“vendoring”) so that the developer can ensure compatibility with newer
versions before providing updates to users.</p>
<p>The two recommended use cases for this distribution are described below.</p>
<section id="python-application">
<h3><span class="section-number">4.4.1. </span>Python Application<a class="headerlink" href="#python-application" title="Permalink to this heading">¶</a></h3>
<p>An application written in Python does not necessarily require users to be aware
of that fact. The embedded distribution may be used in this case to include a
private version of Python in an install package. Depending on how transparent it
should be (or conversely, how professional it should appear), there are two
options.</p>
<p>Using a specialized executable as a launcher requires some coding, but provides
the most transparent experience for users. With a customized launcher, there are
no obvious indications that the program is running on Python: icons can be
customized, company and version information can be specified, and file
associations behave properly. In most cases, a custom launcher should simply be
able to call <code class="docutils literal notranslate"><span class="pre">Py_Main</span></code> with a hard-coded command line.</p>
<p>The simpler approach is to provide a batch file or generated shortcut that
directly calls the <code class="docutils literal notranslate"><span class="pre">python.exe</span></code> or <code class="docutils literal notranslate"><span class="pre">pythonw.exe</span></code> with the required
command-line arguments. In this case, the application will appear to be Python
and not its actual name, and users may have trouble distinguishing it from other
running Python processes or file associations.</p>
<p>With the latter approach, packages should be installed as directories alongside
the Python executable to ensure they are available on the path. With the
specialized launcher, packages can be located in other locations as there is an
opportunity to specify the search path before launching the application.</p>
</section>
<section id="embedding-python">
<h3><span class="section-number">4.4.2. </span>Embedding Python<a class="headerlink" href="#embedding-python" title="Permalink to this heading">¶</a></h3>
<p>Applications written in native code often require some form of scripting
language, and the embedded Python distribution can be used for this purpose. In
general, the majority of the application is in native code, and some part will
either invoke <code class="docutils literal notranslate"><span class="pre">python.exe</span></code> or directly use <code class="docutils literal notranslate"><span class="pre">python3.dll</span></code>. For either case,
extracting the embedded distribution to a subdirectory of the application
installation is sufficient to provide a loadable Python interpreter.</p>
<p>As with the application use, packages can be installed to any location as there
is an opportunity to specify search paths before initializing the interpreter.
Otherwise, there is no fundamental differences between using the embedded
distribution and a regular installation.</p>
</section>
</section>
<section id="alternative-bundles">
<h2><span class="section-number">4.5. </span>Alternative bundles<a class="headerlink" href="#alternative-bundles" title="Permalink to this heading">¶</a></h2>
<p>Besides the standard CPython distribution, there are modified packages including
additional functionality. The following is a list of popular versions and their
key features:</p>
<dl>
<dt><a class="reference external" href="https://www.activestate.com/products/python/">ActivePython</a></dt><dd><p>Installer with multi-platform compatibility, documentation, PyWin32</p>
</dd>
<dt><a class="reference external" href="https://www.anaconda.com/download/">Anaconda</a></dt><dd><p>Popular scientific modules (such as numpy, scipy and pandas) and the
<code class="docutils literal notranslate"><span class="pre">conda</span></code> package manager.</p>
</dd>
<dt><a class="reference external" href="https://www.enthought.com/edm/">Enthought Deployment Manager</a></dt><dd><p>“The Next Generation Python Environment and Package Manager”.</p>
<p>Previously Enthought provided Canopy, but it <a class="reference external" href="https://support.enthought.com/hc/en-us/articles/360038600051-Canopy-GUI-end-of-life-transition-to-the-Enthought-Deployment-Manager-EDM-and-Visual-Studio-Code">reached end of life in 2016</a>.</p>
</dd>
<dt><a class="reference external" href="https://winpython.github.io/">WinPython</a></dt><dd><p>Windows-specific distribution with prebuilt scientific packages and
tools for building packages.</p>
</dd>
</dl>
<p>Note that these packages may not include the latest versions of Python or
other libraries, and are not maintained or supported by the core Python team.</p>
</section>
<section id="configuring-python">
<h2><span class="section-number">4.6. </span>Configuring Python<a class="headerlink" href="#configuring-python" title="Permalink to this heading">¶</a></h2>
<p>To run Python conveniently from a command prompt, you might consider changing
some default environment variables in Windows. While the installer provides an
option to configure the PATH and PATHEXT variables for you, this is only
reliable for a single, system-wide installation. If you regularly use multiple
versions of Python, consider using the <a class="reference internal" href="#launcher"><span class="std std-ref">Python Launcher for Windows</span></a>.</p>
<section id="excursus-setting-environment-variables">
<span id="setting-envvars"></span><h3><span class="section-number">4.6.1. </span>Excursus: Setting environment variables<a class="headerlink" href="#excursus-setting-environment-variables" title="Permalink to this heading">¶</a></h3>
<p>Windows allows environment variables to be configured permanently at both the
User level and the System level, or temporarily in a command prompt.</p>
<p>To temporarily set environment variables, open Command Prompt and use the
<strong class="command">set</strong> command:</p>
<div class="highlight-doscon notranslate"><div class="highlight"><pre><span></span><span class="gp">C:\></span><span class="k">set</span> <span class="nv">PATH</span><span class="p">=</span>C:\Program Files\Python 3.9;<span class="nv">%PATH%</span>
<span class="gp">C:\></span><span class="k">set</span> <span class="nv">PYTHONPATH</span><span class="p">=</span><span class="nv">%PYTHONPATH%</span>;C:\My_python_lib
<span class="gp">C:\></span>python
</pre></div>
</div>
<p>These changes will apply to any further commands executed in that console, and
will be inherited by any applications started from the console.</p>
<p>Including the variable name within percent signs will expand to the existing
value, allowing you to add your new value at either the start or the end.
Modifying <span class="target" id="index-9"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> by adding the directory containing
<strong class="program">python.exe</strong> to the start is a common way to ensure the correct version
of Python is launched.</p>
<p>To permanently modify the default environment variables, click Start and search
for ‘edit environment variables’, or open System properties, <span class="guilabel">Advanced
system settings</span> and click the <span class="guilabel">Environment Variables</span> button.
In this dialog, you can add or modify User and System variables. To change
System variables, you need non-restricted access to your machine
(i.e. Administrator rights).</p>
<div class="admonition note">
<p class="admonition-title">Not</p>
<p>Windows will concatenate User variables <em>after</em> System variables, which may
cause unexpected results when modifying <span class="target" id="index-10"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>.</p>
<p>The <span class="target" id="index-11"></span><a class="reference internal" href="cmdline.html#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a> variable is used by all versions of Python,
so you should not permanently configure it unless the listed paths
only include code that is compatible with all of your installed Python
versions.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/procthread/environment-variables">https://docs.microsoft.com/en-us/windows/win32/procthread/environment-variables</a></dt><dd><p>Overview of environment variables on Windows</p>
</dd>
<dt><a class="reference external" href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1">https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1</a></dt><dd><p>The <code class="docutils literal notranslate"><span class="pre">set</span></code> command, for temporarily modifying environment variables</p>
</dd>
<dt><a class="reference external" href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx">https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx</a></dt><dd><p>The <code class="docutils literal notranslate"><span class="pre">setx</span></code> command, for permanently modifying environment variables</p>
</dd>
</dl>
</div>
</section>
<section id="finding-the-python-executable">
<span id="windows-path-mod"></span><h3><span class="section-number">4.6.2. </span>Finding the Python executable<a class="headerlink" href="#finding-the-python-executable" title="Permalink to this heading">¶</a></h3>
<div class="versionchanged">
<p><span class="versionmodified changed">3.5 sürümünde değişti.</span></p>
</div>
<p>Besides using the automatically created start menu entry for the Python
interpreter, you might want to start Python in the command prompt. The
installer has an option to set that up for you.</p>
<p>On the first page of the installer, an option labelled “Add Python to PATH”
may be selected to have the installer add the install location into the
<span class="target" id="index-12"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>. The location of the <code class="file docutils literal notranslate"><span class="pre">Scripts\</span></code> folder is also added.
This allows you to type <strong class="command">python</strong> to run the interpreter, and
<strong class="command">pip</strong> for the package installer. Thus, you can also execute your
scripts with command line options, see <a class="reference internal" href="cmdline.html#using-on-cmdline"><span class="std std-ref">Command line</span></a> documentation.</p>
<p>If you don’t enable this option at install time, you can always re-run the
installer, select Modify, and enable it. Alternatively, you can manually
modify the <span class="target" id="index-13"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> using the directions in <a class="reference internal" href="#setting-envvars"><span class="std std-ref">Excursus: Setting environment variables</span></a>. You
need to set your <span class="target" id="index-14"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> environment variable to include the directory
of your Python installation, delimited by a semicolon from other entries. An
example variable could look like this (assuming the first two entries already
existed):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.9
</pre></div>
</div>
</section>
</section>
<section id="utf-8-mode">
<span id="win-utf8-mode"></span><h2><span class="section-number">4.7. </span>UTF-8 mode<a class="headerlink" href="#utf-8-mode" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">3.7 sürümünde geldi.</span></p>
</div>
<p>Windows still uses legacy encodings for the system encoding (the ANSI Code
Page). Python uses it for the default encoding of text files (e.g.
<a class="reference internal" href="../library/locale.html#locale.getencoding" title="locale.getencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.getencoding()</span></code></a>).</p>
<p>This may cause issues because UTF-8 is widely used on the internet
and most Unix systems, including WSL (Windows Subsystem for Linux).</p>
<p>You can use the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a> to change the default text
encoding to UTF-8. You can enable the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a> via
the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8</span></code> command line option, or the <code class="docutils literal notranslate"><span class="pre">PYTHONUTF8=1</span></code> environment
variable. See <span class="target" id="index-15"></span><a class="reference internal" href="cmdline.html#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8</span></code></a> for enabling UTF-8 mode, and
<a class="reference internal" href="#setting-envvars"><span class="std std-ref">Excursus: Setting environment variables</span></a> for how to modify environment variables.</p>
<p>When the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a> is enabled, you can still use the
system encoding (the ANSI Code Page) via the “mbcs” codec.</p>
<p>Note that adding <code class="docutils literal notranslate"><span class="pre">PYTHONUTF8=1</span></code> to the default environment variables
will affect all Python 3.7+ applications on your system.
If you have any Python 3.7+ applications which rely on the legacy
system encoding, it is recommended to set the environment variable
temporarily or use the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8</span></code> command line option.</p>
<div class="admonition note">
<p class="admonition-title">Not</p>
<p>Even when UTF-8 mode is disabled, Python uses UTF-8 by default
on Windows for:</p>
<ul class="simple">
<li><p>Console I/O including standard I/O (see <span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0528/"><strong>PEP 528</strong></a> for details).</p></li>
<li><p>The <a class="reference internal" href="../glossary.html#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding</span></a>
(see <span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-0529/"><strong>PEP 529</strong></a> for details).</p></li>
</ul>
</div>
</section>
<section id="python-launcher-for-windows">
<span id="launcher"></span><h2><span class="section-number">4.8. </span>Python Launcher for Windows<a class="headerlink" href="#python-launcher-for-windows" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">3.3 sürümünde geldi.</span></p>
</div>
<p>The Python launcher for Windows is a utility which aids in locating and
executing of different Python versions. It allows scripts (or the
command-line) to indicate a preference for a specific Python version, and
will locate and execute that version.</p>
<p>Unlike the <span class="target" id="index-18"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code> variable, the launcher will correctly select the most
appropriate version of Python. It will prefer per-user installations over
system-wide ones, and orders by language version rather than using the most
recently installed version.</p>
<p>The launcher was originally specified in <span class="target" id="index-19"></span><a class="pep reference external" href="https://peps.python.org/pep-0397/"><strong>PEP 397</strong></a>.</p>
<section id="getting-started">
<h3><span class="section-number">4.8.1. </span>Getting started<a class="headerlink" href="#getting-started" title="Permalink to this heading">¶</a></h3>
<section id="from-the-command-line">
<h4><span class="section-number">4.8.1.1. </span>From the command-line<a class="headerlink" href="#from-the-command-line" title="Permalink to this heading">¶</a></h4>
<div class="versionchanged">
<p><span class="versionmodified changed">3.6 sürümünde değişti.</span></p>
</div>
<p>System-wide installations of Python 3.3 and later will put the launcher on your
<span class="target" id="index-20"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>. The launcher is compatible with all available versions of
Python, so it does not matter which version is installed. To check that the
launcher is available, execute the following command in Command Prompt:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py
</pre></div>
</div>
<p>You should find that the latest version of Python you have installed is
started - it can be exited as normal, and any additional command-line
arguments specified will be sent directly to Python.</p>
<p>If you have multiple versions of Python installed (e.g., 3.7 and 3.11) you
will have noticed that Python 3.11 was started - to launch Python 3.7, try
the command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py -3.7
</pre></div>
</div>
<p>If you want the latest version of Python 2 you have installed, try the
command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py -2
</pre></div>
</div>
<p>If you see the following error, you do not have the launcher installed:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>'py' is not recognized as an internal or external command,
operable program or batch file.
</pre></div>
</div>
<p>The command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py --list
</pre></div>
</div>
<p>displays the currently installed version(s) of Python.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">-x.y</span></code> argument is the short form of the <code class="docutils literal notranslate"><span class="pre">-V:Company/Tag</span></code> argument,
which allows selecting a specific Python runtime, including those that may have
come from somewhere other than python.org. Any runtime registered by following
<span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0514/"><strong>PEP 514</strong></a> will be discoverable. The <code class="docutils literal notranslate"><span class="pre">--list</span></code> command lists all available
runtimes using the <code class="docutils literal notranslate"><span class="pre">-V:</span></code> format.</p>
<p>When using the <code class="docutils literal notranslate"><span class="pre">-V:</span></code> argument, specifying the Company will limit selection to
runtimes from that provider, while specifying only the Tag will select from all
providers. Note that omitting the slash implies a tag:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># Select any '3.*' tagged runtime
py -V:3
# Select any 'PythonCore' released runtime
py -V:PythonCore/
# Select PythonCore's latest Python 3 runtime
py -V:PythonCore/3
</pre></div>
</div>
<p>The short form of the argument (<code class="docutils literal notranslate"><span class="pre">-3</span></code>) only ever selects from core Python
releases, and not other distributions. However, the longer form (<code class="docutils literal notranslate"><span class="pre">-V:3</span></code>) will
select from any.</p>
<p>The Company is matched on the full string, case-insenitive. The Tag is matched
oneither the full string, or a prefix, provided the next character is a dot or a
hyphen. This allows <code class="docutils literal notranslate"><span class="pre">-V:3.1</span></code> to match <code class="docutils literal notranslate"><span class="pre">3.1-32</span></code>, but not <code class="docutils literal notranslate"><span class="pre">3.10</span></code>. Tags are
sorted using numerical ordering (<code class="docutils literal notranslate"><span class="pre">3.10</span></code> is newer than <code class="docutils literal notranslate"><span class="pre">3.1</span></code>), but are
compared using text (<code class="docutils literal notranslate"><span class="pre">-V:3.01</span></code> does not match <code class="docutils literal notranslate"><span class="pre">3.1</span></code>).</p>
</section>
<section id="virtual-environments">
<h4><span class="section-number">4.8.1.2. </span>Virtual environments<a class="headerlink" href="#virtual-environments" title="Permalink to this heading">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">3.5 sürümünde geldi.</span></p>
</div>
<p>If the launcher is run with no explicit Python version specification, and a
virtual environment (created with the standard library <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> module or
the external <code class="docutils literal notranslate"><span class="pre">virtualenv</span></code> tool) active, the launcher will run the virtual
environment’s interpreter rather than the global one. To run the global
interpreter, either deactivate the virtual environment, or explicitly specify
the global Python version.</p>
</section>
<section id="from-a-script">
<h4><span class="section-number">4.8.1.3. </span>From a script<a class="headerlink" href="#from-a-script" title="Permalink to this heading">¶</a></h4>
<p>Let’s create a test Python script - create a file called <code class="docutils literal notranslate"><span class="pre">hello.py</span></code> with the
following contents</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="ch">#! python</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"hello from Python </span><span class="si">%s</span><span class="se">\n</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">version</span><span class="p">,))</span>
</pre></div>
</div>
<p>From the directory in which hello.py lives, execute the command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py hello.py
</pre></div>
</div>
<p>You should notice the version number of your latest Python 2.x installation
is printed. Now try changing the first line to be:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="ch">#! python3</span>
</pre></div>
</div>
<p>Re-executing the command should now print the latest Python 3.x information.
As with the above command-line examples, you can specify a more explicit
version qualifier. Assuming you have Python 3.7 installed, try changing
the first line to <code class="docutils literal notranslate"><span class="pre">#!</span> <span class="pre">python3.7</span></code> and you should find the 3.7
version information printed.</p>
<p>Note that unlike interactive use, a bare “python” will use the latest
version of Python 2.x that you have installed. This is for backward
compatibility and for compatibility with Unix, where the command <code class="docutils literal notranslate"><span class="pre">python</span></code>
typically refers to Python 2.</p>
</section>
<section id="from-file-associations">
<h4><span class="section-number">4.8.1.4. </span>From file associations<a class="headerlink" href="#from-file-associations" title="Permalink to this heading">¶</a></h4>
<p>The launcher should have been associated with Python files (i.e. <code class="docutils literal notranslate"><span class="pre">.py</span></code>,
<code class="docutils literal notranslate"><span class="pre">.pyw</span></code>, <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files) when it was installed. This means that
when you double-click on one of these files from Windows explorer the launcher
will be used, and therefore you can use the same facilities described above to
have the script specify the version which should be used.</p>
<p>The key benefit of this is that a single launcher can support multiple Python
versions at the same time depending on the contents of the first line.</p>
</section>
</section>
<section id="shebang-lines">
<h3><span class="section-number">4.8.2. </span>Shebang Lines<a class="headerlink" href="#shebang-lines" title="Permalink 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. This launcher allows the same facilities to
be used with Python scripts on Windows and the examples above demonstrate their
use.</p>