aa7a24d4fc5cb9daf168786a6305fee593e24a6c
[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 ### List all available python version
63
64 ```bash
65 pyenv install --list
66 ```
67
68 ```txt
69   3.9.1
70   activepython-3.6.0
71   anaconda3-2020.11
72   graalpython-20.3.0
73   ironpython-2.7.7
74   jython-2.7.2
75   micropython-1.13
76   miniforge3-4.9.2
77   pypy3.7-7.3.3
78   pyston-0.6.1
79   stackless-3.7.5
80 ```
81
82 ### Install Python versions
83
84 ```bash
85 pyenv install <version>
86 pyenv rehash
87 ```
88
89 ### pyenv versions
90
91 List installed versions:
92
93 ```bash
94 pyenv versions
95 ```
96
97 ### pyenv local
98
99 Pin an application to a specific Python version:
100
101 ```bash
102 pyenv local 2.7.6
103 ```
104
105 Unset the local version:
106
107 ```bash
108 pyenv local --unset
109 ```
110
111 (setting the version works per-folder)
112
113 ### List existing virtualenvs
114
115 ```bash
116 pyenv virtualenvs
117 ```
118
119 ### Create virtualenv
120
121 From current version with name "venv35":
122
123 ```bash
124 pyenv virtualenv venv35
125 ```
126
127 From version 2.7.10 with name "venv27":
128
129 ```bash
130 pyenv virtualenv 2.7.10
131 venv27
132 ```
133
134 ### Activate/deactivate
135
136 ```bash
137 pyenv activate <name>
138 pyenv deactivate
139 ```
140
141 ### Delete existing virtualenv
142
143 ```bash
144 pyenv uninstall venv27
145 ```