You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MAC_SETUP.md
+36-5Lines changed: 36 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ test their code.
51
51
## Installing multiple Python versions
52
52
53
53
54
-
1. See the available Python versions with
54
+
1. See the available Python versions with [pyenv](https://github.com/pyenv/pyenv),=.
55
55
56
56
```console
57
57
pyenv install --list
@@ -88,6 +88,10 @@ test their code.
88
88
```console
89
89
$ pyenv install 3.7.6
90
90
```
91
+
* 3.8.1 (latest 3.8.x release)
92
+
```console
93
+
$ pyenv install 3.8.1
94
+
```
91
95
92
96
1. After you have installed a python version through pyenv,
93
97
verify that you are now using the pyenv Python shim.
@@ -97,19 +101,46 @@ test their code.
97
101
~/.pyenv/shims/python
98
102
```
99
103
104
+
## Managing python versions using Pyenv global
105
+
Pyenv allows you to configure the prioirty order for your python installs.
106
+
107
+
```
108
+
pyenv global 3.8.1 3.7.6 3.6.10 3.5.9 2.7.17
109
+
```
110
+
111
+
This will make python and python3 point to Python 3.8.1. python2 will go to 2.7.17. You can also further specify versions, such as python3.6 to use that version.
112
+
113
+
## Python virtual environments
114
+
Using Virtual Environments is fairly common across the Python community. While there is built in support in python for creating environments, there are also other tools that the community has embraced. Option 1 relies on python itself, Option 2 uses an additional tool that some users may prefer.
115
+
116
+
In either case, you can create and source virtual environments, `python` will point to this virtual environment, not a global python install. Each virtual environment can have its own set of packages that can be different from others.
117
+
118
+
119
+
### Option 1: Using builtin support, venv
120
+
Python ships with support of its own to create virtual environments. You can [create a virtual environment](https://docs.python.org/3/library/venv.html).
121
+
122
+
```
123
+
cd python-docs-samples
124
+
python3 -m venv venv-name
125
+
source venv-name/bin/activate
126
+
```
127
+
128
+
Typically you will name the venv `venv`, or `venv38` for a python 3.8 venv.
129
+
100
130
101
-
## Using pyenv and pyenv-virtualenv to manage your Python versions
131
+
## Option 2: Using pyenv-virtualenv to manage your Python versions
132
+
You can also use an extension for pyenv that will assist in managing virtual environments. This allows you to use `pyenv local` to automatically use the create virtual environment
102
133
103
134
1. Change to the desired source directory.
104
135
105
136
```console
106
137
cd ~/src/python-docs-samples
107
138
```
108
139
109
-
1. Create a virtualenv using `pyenv virtualenv`.
140
+
1. Create a virtualenv for python 3.8.1 using `pyenv virtualenv`.
110
141
111
142
```console
112
-
pyenv virtualenv 3.7.6 python-docs-samples
143
+
pyenv virtualenv 3.8.1 python-docs-samples
113
144
```
114
145
115
146
This creates a virtualenv folder within `~/.pyenv/versions/`.
@@ -118,7 +149,7 @@ test their code.
118
149
119
150
```console
120
151
# pyenv local [name of virtualenv] [list of python versions to use]
121
-
pyenv local python-docs-samples 3.6.10 3.7.6 3.5.9 2.7.17
152
+
pyenv local python-docs-samples 3.8.1 3.7.6 3.6.10 3.5.9 2.7.17
122
153
```
123
154
124
155
1. Now, when you `cd` into the source directory or a subdirectory within it,
0 commit comments