Skip to content

Commit 72af0a0

Browse files
authored
Fix pyenv FAQ env var commands
When using pyenv and global not set (defaulting to system) or global set to `system` the Launcher was unable to determine correct version to use. Fixed by using `pyenv exec` to correctly determine current Python version instead of parsing pyenv config files. Fixes brettcannon#141
1 parent 502f4a7 commit 72af0a0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,21 @@ but [U+2502/"Box Drawings Light Vertical"](https://www.compart.com/en/unicode/U+
221221
### How can I make the Python Launcher use my default Python version from pyenv?
222222

223223
If you're using [pyenv](https://github.com/pyenv/pyenv) to manage your Python
224-
versions, you'll want to grab the major and minor version from the first Python
225-
version listed in your default
226-
[pyenv version file](https://github.com/pyenv/pyenv#choosing-the-python-version).
224+
versions, you'll want to set the version the Launcher to the pyenv
225+
[global version](https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-global).
227226

228-
You can add this line to your `.zshrc` or `.bashrc` file:
227+
Add these lines to your `.zshrc` or `.bashrc` file:
229228

230229
```sh
231-
export PY_PYTHON=$(head -n 1 $(pyenv root)/version | cut -d "." -f 1,2)
230+
export PY_PYTHON=$(pyenv exec python -c "import sys; print('.'.join(map(str, sys.version_info[0:2])))")
231+
export PY_PYTHON3=$(pyenv exec python3 -c "import sys; print(*sys.version_info[0:2], sep='.')")
232232
```
233233

234-
Or this line in your `~/.config/fish/config.fish` file:
234+
Or these lines to your `~/.config/fish/config.fish` file:
235235

236236
```sh
237-
set -gx PY_PYTHON (head -n 1 (pyenv root)/version | cut -d "." -f 1,2)
237+
set -gx PY_PYTHON (pyenv exec python -c "import sys; print('.'.join(map(str, sys.version_info[0:2])))")
238+
set -gx PY_PYTHON3 (pyenv exec python3 -c "import sys; print(*sys.version_info[0:2], sep='.')")
238239
```
239240

240241
## Appendix

0 commit comments

Comments
 (0)