Last active
September 20, 2024 22:12
-
-
Save entropiae/326611addf6662d1d8fbf5792ab9a770 to your computer and use it in GitHub Desktop.
Install pyenv on Ubuntu 18.04 + Fish shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install pyenv on Ubuntu 18.04 + fish shell | |
- Install the packages required to compile Python | |
$ sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev | |
- Download pyenv code from github | |
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
- Define environment variable PYENV_ROOT to point to the path where pyenv repo is cloned | |
$ echo "set --export PYENV_ROOT $HOME/.pyenv" > ~/.config/fish/conf.d/pyenv.fish | |
- Add $PYENV_ROOT/bin to your $PATH for access to the pyenv command-line utility | |
$ set -U fish_user_paths $HOME/.pyenv/bin $fish_user_paths | |
- Add pyenv init to your shell to enable shims and autocompletion. | |
$ echo -e '\n\n# pyenv init\nif command -v pyenv 1>/dev/null 2>&1\n pyenv init - | source\nend' >> ~/.config/fish/config.fish | |
- Install pyenv-virtualenv | |
$ git clone https://github.com/pyenv/pyenv-virtualenv.git (pyenv root)/plugins/pyenv-virtualenv | |
- Enable virtualenv autocomplete | |
$ echo -e "\n# Enable virtualenv autocomplete\nstatus --is-interactive; and pyenv init - | source\nstatus --is-interactive; and pyenv virtualenv-init - | source\n" >> ~/.config/fish/conf.d/pyenv.fish | |
###################################### | |
- List available Python versions | |
$ pyenv install --list | |
- Install a version | |
$ pyenv install 2.7.16 | |
- Create a virtualenv | |
$ pyenv virtualenv 3.7.4 my_venv | |
- Activate a virtualenv | |
pyenv activate my_venv | |
@LukeDRussell I'm glad it helped! 😃
Thanks bro. It was really helpful
Thanks for your sharing.
When I following your guide, I found that pyenv does not override the system python binary.
Here is the related issue link.
pyenv/pyenv#1906
You could replace the pyenv init -
by pyenv init --path
in line 16.
That can solve the problem.
Thanks!! It saved me.
Amazing - thank you so much
I'm on WSL and for some reason fish paths don't persist, so I had to add set -U fish_user_paths $HOME/.pyenv/bin $fish_user_paths
to my ~/.config/fish/config.fish
in order to get line 16 to work - other than that, fantastic!
Awesome!
Thanks so much!! Other tutorials made me reinstall WSL ㅠㅠ
Thanks to you, I got it!
This still works great, i'm using arch btw.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Love your work, I've spent hours trying to get this working on my latest Fedora build.
Thanks so much.