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
+39-3Lines changed: 39 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,16 +113,52 @@ This will make python and python3 point to Python 3.8.1. python2 will use 2.7.17
113
113
## Python virtual environments
114
114
Using [Virtual Environments](https://docs.python.org/3/library/venv.html) prevents inadvertent modifications to your global python install. Once created and sourced, calls to `python` will uses this virtual environment, not a global python install. Each virtual environment can have its own set of packages that can be different from others.
115
115
116
-
To create a virtual environment, run `python3 -m venv`.
116
+
117
+
### Using Python 3+ venv
118
+
Python has builtin support for creating virtual environments, accessible by running `python -m venv`.
117
119
118
120
```
119
121
cd python-docs-samples
120
-
python3 -m venv venv-name
121
-
source venv-name/bin/activate
122
+
python -m venv [venv-name]
123
+
source [venv-name]/bin/activate
122
124
```
123
125
124
126
Typically you will name the venv `venv`, or `venv38` for a python 3.8 venv.
125
127
128
+
129
+
### Using pyenv-virtualenv
130
+
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 created virtual environment. You can install this by running `$ brew install pyenv-virtualenv`
131
+
132
+
1. Change to the desired source directory.
133
+
134
+
```console
135
+
cd ~/src/python-docs-samples
136
+
```
137
+
138
+
1. Create a virtualenv for python 3.8.1 using `pyenv virtualenv`.
139
+
140
+
```console
141
+
pyenv virtualenv 3.8.1 python-docs-samples
142
+
```
143
+
144
+
This creates a virtualenv folder within `~/.pyenv/versions/`.
145
+
146
+
1. Set the local Python version(s) with `pyenv local`
147
+
148
+
```console
149
+
# pyenv local [name of virtualenv] [list of python versions to use]
150
+
pyenv local python-docs-samples 3.8.1 3.7.6 3.6.10 3.5.9 2.7.17
151
+
```
152
+
153
+
1. Now, when you `cd` into the source directory or a subdirectory within it,
154
+
pyenv will make your virtualenv the default Python. Since you specified
155
+
more than one version, it will also add binaries like `python36` and
156
+
`python27` to your PATH, which nox uses when picking Python interpreters.
157
+
158
+
1. Add `.python-version` to your [global gitignore
0 commit comments