Last active
February 20, 2020 14:22
-
-
Save AlexandreQuintela/fe0bfc5e0a3806ee17ccb01aedef14f2 to your computer and use it in GitHub Desktop.
Instalando e usando o Pyenv no Ubuntu
This file contains hidden or 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
# The definitive guide to setup my Python workspace | |
# Author: Henrique Bastos <[email protected]> | |
# Alterações para Ubuntu e sabores: Alexandre Quintela <[email protected]> | |
PY3=3.8.1 | |
PY3TOOLS="youtube-dl s3cmd fabric pytest" | |
VENVS=~/.venvs | |
PROJS=~/projetos | |
# Install dependencies | |
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ | |
libreadline-dev libsqlite3-dev wget curl llvm gettext libncurses5-dev tk-dev tcl-dev \ | |
blt-dev libgdbm-dev git python-dev python3-dev | |
# All my virtualenvs are here... | |
mkdir -p $VENVS | |
# All my projects are here... | |
mkdir -p $PROJS | |
# Install Pyenv | |
git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
# Initialize pyenv | |
PYENV_ROOT="$HOME/.pyenv" | |
PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" | |
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi | |
# Define environment variable PYENV_ROOT | |
cat <<EOT >> .bashrc | |
# Define environment variable PYENV_ROOT | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
EOT | |
# Set Pyenv in .bashrc and initialize pyenv | |
cat <<"EOT" >> .bashrc | |
# Pyenv initialization | |
eval "$(pyenv init -)" | |
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi | |
EOT | |
# Enable shims and autocompletion | |
cat <<"EOT" >> .bashrc | |
# Enable shims and autocompletion | |
if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)"; fi | |
EOT | |
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv | |
cat <<EOT >> .bashrc | |
# Virtualenv-wrapper directories | |
export WORKON_HOME=$VENVS | |
export PROJECT_HOME=$PROJS | |
EOT | |
# Install Python versions | |
pyenv install $PY3 | |
# Prepare virtual environments | |
pyenv virtualenv $PY3 jupyter38 | |
pyenv virtualenv $PY3 tools38 | |
~/.pyenv/versions/$PY3/bin/pip install --upgrade pip | |
~/.pyenv/versions/jupyter38/bin/pip install --upgrade pip | |
~/.pyenv/versions/tools38/bin/pip install --upgrade pip | |
# Install Jupyter | |
~/.pyenv/versions/jupyter38/bin/pip install jupyter | |
~/.pyenv/versions/jupyter38/bin/python -m ipykernel install --user | |
~/.pyenv/versions/jupyter38/bin/pip install jupyter_nbextensions_configurator rise | |
~/.pyenv/versions/jupyter38/bin/jupyter nbextensions_configurator enable --user | |
# Install Python3 Tools | |
~/.pyenv/versions/tools38/bin/pip install $PY3TOOLS | |
# Install virtualenvwrapper | |
~/.pyenv/versions/tools38/bin/pip install virtualenvwrapper | |
cat <<"EOT" >> .bashrc | |
# Virtualenv Wrapper initialization | |
VIRTUALENVWRAPPER_PYTHON=~/.pyenv/versions/tools38/bin/python | |
source ~/.pyenv/versions/tools38/bin/virtualenvwrapper.sh | |
EOT | |
# Protect lib dir for global interpreters VERIFICAR | |
# chmod -R -w ~/.pyenv/versions/$PY3/lib/ | |
# Setup path order | |
pyenv global $PY3 jupyter38 tools38 | |
# Check everything | |
pyenv which python | grep -q "$PY3" && echo "✓ $PY3" | |
pyenv which jupyter | grep -q "jupyter38" && echo "✓ jupyter38" | |
pyenv which ipython | grep -q "jupyter38" && echo "✓ ipython" | |
pyenv which youtube-dl | grep -q "tools38" && echo "✓ tools38" | |
echo "Done! Restart the terminal." | |
. ~/.bashrc | |
# Cria um profile padrão do iPython | |
ipython profile create | |
# Faz Download configuracao Ipyhton | |
wget https://github.com/henriquebastos/ipython-config/archive/master.zip | |
# Descompacta configurações | |
unzip -o -q master.zip -d ~/tmpipython | |
# Move para i Ipython | |
# mv -r ~/tmpipython/ipython-config-master/* ~/.ipython/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment