Header Ads Widget

Ticker

6/recent/ticker-posts

Windows: administrador de versiones de Python

 Para Ruby, tenemos RVM - Ruby Version Manager y para NodeJS tenemos NVM - Node Version Manager .

¿Cuál es el administrador de versiones de Python?
Hay muchos métodos, pero decimos sobre el método más simple: usepy.exelocalizar enC:\Windows\py.exe

Enumere todas las Python disponibles en su máquina:

C:\Windows\py.exe

Resultado:

1
2
3
4
5
C:\Users\Administrator>py -0
Installed Pythons found by py Launcher for Windows
 -3.8-64 *
 -3.7-64
 -2.7-64

Ayuda completa sobre py.exe:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dieciséis
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
sesenta y cinco
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
C:\Users\Administrator>py --help
Python Launcher for Windows Version 3.8.5150.1013
 
usage:
py [launcher-args] [python-args] script [script-args]
 
Launcher arguments:
 
-2     : Launch the latest Python 2.x version
-3     : Launch the latest Python 3.x version
-X.Y   : Launch the specified Python version
     The above all default to 64 bit if a matching 64 bit python is present.
-X.Y-32: Launch the specified 32bit Python version
-X-32  : Launch the latest 32bit Python X version
-X.Y-64: Launch the specified 64bit Python version
-X-64  : Launch the latest 64bit Python X version
-0  --list       : List the available pythons
-0p --list-paths : List with paths
 
The following help text is from Python:
 
usage: C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe
[option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-b     : issue warnings about str(bytes_instance), str(bytearray_instance)
         and comparing bytes/bytearray with str. (-bb: issue errors)
-B     : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d     : debug output from parser; also PYTHONDEBUG=x
-E     : ignore PYTHON* environment variables (such as PYTHONPATH)
-h     : print this help message and exit (also --help)
-i     : inspect interactively after running script; forces a prompt even
         if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-I     : isolate Python from the user's environment (implies -E and -s)
-m mod : run library module as a script (terminates option list)
-O     : remove assert and __debug__-dependent statements; add .opt-1 before
         .pyc extension; also PYTHONOPTIMIZE=x
-OO    : do -O changes and also discard docstrings; add .opt-2 before
         .pyc extension
-q     : don't print version and copyright messages on interactive startup
-s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S     : don't imply 'import site' on initialization
-u     : force the stdout and stderr streams to be unbuffered;
         this option has no effect on stdin; also PYTHONUNBUFFERED=x
-v     : verbose (trace import statements); also PYTHONVERBOSE=x
         can be supplied multiple times to increase verbosity
-V     : print the Python version number and exit (also --version)
         when given twice, print more information about the build
-W arg : warning control; arg is action:message:category:module:lineno
         also PYTHONWARNINGS=arg
-x     : skip first line of source, allowing use of non-Unix forms of #!cmd
-X opt : set implementation-specific option. The following options are available
:
 
         -X faulthandler: enable faulthandler
         -X showrefcount: output the total reference count and number of used
             memory blocks when the program finishes or after each statement in
the
             interactive interpreter. This only works on debug builds
         -X tracemalloc: start tracing Python memory allocations using the
             tracemalloc module. By default, only the most recent frame is store
d in a
             traceback of a trace. Use -X tracemalloc=NFRAME to start tracing wi
th a
             traceback limit of NFRAME frames
         -X showalloccount: output the total count of allocated objects for each
 
             type when the program finishes. This only works when Python was bui
lt with
             COUNT_ALLOCS defined
         -X importtime: show how long each import takes. It shows module name,
             cumulative time (including nested imports) and self time (excluding
 
             nested imports). Note that its output may be broken in multi-thread
ed
             application. Typical usage is python3 -X importtime -c 'import asyn
cio'
         -X dev: enable CPythonâ?Ts â?odevelopment modeâ??, introducing addition
al runtime
             checks which are too expensive to be enabled by default. Effect of
the
             developer mode:
                * Add default warning filter, as -W default
                * Install debug hooks on memory allocators: see the PyMem_SetupD
ebugHooks() C function
                * Enable the faulthandler module to dump the Python traceback on
 a crash
                * Enable asyncio debug mode
                * Set the dev_mode attribute of sys.flags to True
                * io.IOBase destructor logs close() exceptions
         -X utf8: enable UTF-8 mode for operating system interfaces, overriding
the default
             locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even w
hen it would
             otherwise activate automatically)
         -X pycache_prefix=PATH: enable writing .pyc files to a parallel tree ro
oted at the
             given directory instead of to the code tree
 
--check-hash-based-pycs always|default|never:
    control how Python invalidates hash-based .pyc files
file   : program read from script file
-      : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]
 
Other environment variables:
PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH   : ';'-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
PYTHONHOME   : alternate <prefix> directory (or <prefix>;<exec_prefix>).
               The default module search path uses <prefix>\python{major}{minor}
.
PYTHONCASEOK : ignore case in 'import' statements (Windows).
PYTHONUTF8: if set to 1, enable the UTF-8 mode.
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.
PYTHONHASHSEED: if this variable is set to 'random', a random value is used
   to seed the hashes of str and bytes objects.  It can also be set to an
   integer in the range [0,4294967295] to get hash values with a
   predictable seed.
PYTHONMALLOC: set the Python memory allocators and/or install debug hooks
   on Python memory allocators. Use PYTHONMALLOC=debug to install debug
   hooks.
PYTHONCOERCECLOCALE: if this variable is set to 0, it disables the locale
   coercion behavior. Use PYTHONCOERCECLOCALE=warn to request display of
   locale coercion and locale compatibility warnings on stderr.
PYTHONBREAKPOINT: if this variable is set to 0, it disables the default
   debugger. It can be set to the callable of your debugger of choice.
PYTHONDEVMODE: enable the development mode.
PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.

py en windows

Algunos ejemplos:

1
2
3
4
5
6
7
8
C:\Users\Administrator>py -2.7 -V
Python 2.7.15
 
C:\Users\Administrator>py -3.7 -V
Python 3.7.9
 
C:\Users\Administrator>py -V
Python 3.8.5

Nota: cuando instale Python, no marque enAdd Python X.X to PATH
instalar Python 3.8 Windows

PIP - Administrador de paquetes de Python
Para pip , ¿cómo cambiar de versión?

Mando: py -{version} -m pip

Ejemplo:

1
2
3
4
5
6
7
8
9
10
11
C:\Users\Administrator>py -m pip -V
pip 20.1.1 from C:\Users\Administrator\AppData\Local\Programs\Python\Python38\li
b\site-packages\pip (python 3.8)
 
C:\Users\Administrator>py -3.7 -m pip -V
pip 20.1.1 from C:\Users\Administrator\AppData\Local\Programs\Python\Python37\li
b\site-packages\pip (python 3.7)
 
C:\Users\Administrator>py -2.7 -m pip -V
pip 9.0.3 from C:\Users\Administrator\.windows-build-tools\python27\lib\site-pac
kages (python 2.7)

Publicar un comentario

0 Comentarios