refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / pyenv / README.md
1 ---
2 title: pyenv
3 homepage: https://github.com/pyenv/pyenv
4 tagline: |
5   pyenv: Simple Python Version Management
6 ---
7
8 To update run `pyenv update`.
9
10 ### How to Install pyenv on macOS
11
12 Make sure that you already have Xcode tools installed:
13
14 ```bash
15 xcode-select --install
16 ```
17
18 ### How to Install pyenv on Linux
19
20 Make sure that you already have the necessary build tools installed:
21
22 ```bash
23 # required
24 sudo apt update
25 sudo apt install -y build-essential zlib1g-dev libssl-dev
26
27 # recommended
28 sudo apt install -y libreadline-dev libbz2-dev libsqlite3-dev
29 ```
30
31 ## Cheat Sheet
32
33 > `pyenv` lets you install and switch between different versions of `python` as
34 > the logged in user. It doesn't require admin permissions, and doesn't
35 > interfere with your system version of python.
36
37 Be sure to **follow the onscreen instructions** after the install (and the
38 pre-requisites above).
39
40 Here's how you can check for the latest version:
41
42 ```bash
43 pyenv install --list | grep -v -- - | tail -n 1
44 #>   3.9.1
45 ```
46
47 And install it:
48
49 ```bash
50 pyenv install -v 3.9.1
51 #> Installed Python-3.9.1 to ~/.pyenv/versions/3.9.1
52 ```
53
54 And use it:
55
56 ```bash
57 pyenv global 3.9.1
58 python --version
59 #> Python 3.9.1
60 ```
61
62 Revert back to your system python:
63
64 ```bash
65 pyenv global system
66 ```
67
68 ### List all available python version
69
70 ```bash
71 pyenv install --list
72 ```
73
74 ```txt
75   3.9.1
76   activepython-3.6.0
77   anaconda3-2020.11
78   graalpython-20.3.0
79   ironpython-2.7.7
80   jython-2.7.2
81   micropython-1.13
82   miniforge3-4.9.2
83   pypy3.7-7.3.3
84   pyston-0.6.1
85   stackless-3.7.5
86 ```
87
88 ### Install Python versions
89
90 ```bash
91 pyenv install <version>
92 pyenv rehash
93 ```
94
95 ### pyenv versions
96
97 List installed versions:
98
99 ```bash
100 pyenv versions
101 ```
102
103 ### pyenv local
104
105 Pin an application to a specific Python version:
106
107 ```bash
108 pyenv local 2.7.6
109 ```
110
111 Unset the local version:
112
113 ```bash
114 pyenv local --unset
115 ```
116
117 (setting the version works per-folder)
118
119 ### List existing virtualenvs
120
121 ```bash
122 pyenv virtualenvs
123 ```
124
125 ### Create virtualenv
126
127 From current version with name "venv35":
128
129 ```bash
130 pyenv virtualenv venv35
131 ```
132
133 From version 2.7.10 with name "venv27":
134
135 ```bash
136 pyenv virtualenv 2.7.10
137 venv27
138 ```
139
140 ### Activate/deactivate
141
142 ```bash
143 pyenv activate <name>
144 pyenv deactivate
145 ```
146
147 ### Delete existing virtualenv
148
149 ```bash
150 pyenv uninstall venv27
151 ```