Last active
April 14, 2023 15:21
-
-
Save iwatakeshi/4100589053013c86689eaa8759071704 to your computer and use it in GitHub Desktop.
Setup Python on Pop_OS!
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
#!/bin/bash | |
# 1. Install python3 (if applicable) | |
if ! command -v python3 &> /dev/null; then | |
sudo apt update | |
sudo apt install python3 | |
fi | |
# 2. Install pip (if applicable) | |
if ! command -v pip &> /dev/null; then | |
sudo apt update | |
sudo apt install python3-pip | |
fi | |
# 3. Install pipenv | |
sudo -H pip install pipenv | |
# 4. Install the required ubuntu packages to install pyenv | |
sudo apt update | |
sudo apt install -y make build-essential libssl-dev zlib1g-dev \ | |
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ | |
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git | |
# 5. Install pyenv | |
curl https://pyenv.run | bash | |
# 6. Install pipx | |
sudo -H pip install pipx | |
# 7. Run pipx ensurepath | |
pipx ensurepath | |
# 8. Add pyenv to the shell configuration file | |
if [ -n "$ZSH_VERSION" ]; then | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc | |
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc | |
echo 'eval "$(_PIPENV_COMPLETE=zsh_source pipenv)"' >> ~/.zshrc | |
source ~/.zshrc | |
elif [ -n "$BASH_VERSION" ]; then | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc | |
source ~/.bashrc | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment