-
-
Save fernandolcouto/bf0526499ed0470e3935285ad8b89178 to your computer and use it in GitHub Desktop.
The definitive guide to setup my Python workspace
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
# The definitive guide to setup my Python workspace | |
# Author: Henrique Bastos <[email protected]> | |
PY3=3.8.0 | |
#PY2=2.7.16 | |
PY3TOOLS="youtube-dl pandas s3cmd fabric pytest" | |
#PY2TOOLS="rename mercurial" | |
VENVS=~/.ve | |
PROJS=~/workspace | |
# Adapted for or Debian | |
# Install dependencies | |
#brew install openssl readline zlib | |
sudo apt-get install -y 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 aria2 vim libnss3-tools python3-venv liblzma-dev | |
# Install Pyenv | |
#brew install pyenv | |
#brew install pyenv-virtualenv | |
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash | |
# All my virtualenvs are here... | |
mkdir -p $VENVS | |
# All my projects are here... | |
mkdir -p $PROJS | |
# Setup .bash_profile | |
#cat <<EOT >> .bash_profile | |
cat <<EOT >> .bashrc | |
# Virtualenv-wrapper directories | |
export WORKON_HOME=$VENVS | |
export PROJECT_HOME=$PROJS | |
EOT | |
#cat <<"EOT" >> .bash_profile | |
cat <<"EOT" >> .bashrc | |
# Pyenv initialization | |
eval "$(pyenv init -)" | |
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi | |
EOT | |
# Initialize pyenv | |
eval "$(pyenv init -)" | |
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi | |
# Install Python versions | |
pyenv install $PY3 | |
#pyenv install $PY2 | |
# Mojave issue | |
# SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install $PY3 | |
# SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install $PY2 | |
# Prepare virtual environments | |
pyenv virtualenv $PY3 jupyter38 | |
pyenv virtualenv $PY3 tools38 | |
#pyenv virtualenv $PY2 ipython27 | |
#pyenv virtualenv $PY2 tools27 | |
~/.pyenv/versions/$PY3/bin/pip install --upgrade pip | |
#~/.pyenv/versions/$PY2/bin/pip install --upgrade pip | |
~/.pyenv/versions/jupyter38/bin/pip install --upgrade pip | |
~/.pyenv/versions/tools38/bin/pip install --upgrade pip | |
#~/.pyenv/versions/ipython27/bin/pip install --upgrade pip | |
#~/.pyenv/versions/tools27/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 Python2 kernel | |
#~/.pyenv/versions/ipython27/bin/pip install ipykernel | |
#~/.pyenv/versions/ipython27/bin/python -m ipykernel install --user | |
# Install Python3 Tools | |
~/.pyenv/versions/tools38/bin/pip install $PY3TOOLS | |
# Install virtualenvwrapper | |
~/.pyenv/versions/tools38/bin/pip install virtualenvwrapper | |
#cat <<"EOT" >> .bash_profile | |
cat <<"EOT" >> .bashrc | |
# Virtualenv Wrapper initialization | |
VIRTUALENVWRAPPER_PYTHON=~/.pyenv/versions/tools38/bin/python | |
source ~/.pyenv/versions/tools38/bin/virtualenvwrapper.sh | |
EOT | |
# Install Python2 Tools | |
#~/.pyenv/versions/tools27/bin/pip install $PY2TOOLS | |
# Protect lib dir for global interpreters | |
#chmod -R -w ~/.pyenv/versions/$PY2/lib/ | |
chmod -R -w ~/.pyenv/versions/$PY3/lib/ | |
# Setup path order | |
pyenv global $PY3 jupyter38 tools38 | |
#pyenv global $PY2 ipython27 tools27 (I excluded at the above line) | |
# Check everything | |
pyenv which python | grep -q "$PY3" && echo "✓ $PY3" | |
#pyenv which python2 | grep -q "$PY2" && echo "✓ $PY2" | |
pyenv which jupyter | grep -q "jupyter38" && echo "✓ jupyter38" | |
pyenv which ipython | grep -q "jupyter38" && echo "✓ ipython" | |
#pyenv which ipython2 | grep -q "ipython27" && echo "✓ ipython27" | |
pyenv which youtube-dl | grep -q "tools38" && echo "✓ tools38" | |
#pyenv which rename | grep -q "tools27" && echo "✓ tools27" | |
echo "Done! Restart the terminal." | |
# I added this line to the .bashrc | |
# export PATH="$PATH:/home/flcs/.pyenv/bin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Irado!