Django and Python 3 How to Setup pyenv for Multiple Pythons

We need to be doing Django development in Python 3. Unfortunately, we have a lot of projects still in Python 2.7 so switching between the 2 versions can be frustrating. Fortunately pyenv takes the guess work out of switching, and makes it super simple.
Download HD Version next video: Upload Files to django-rest-framework via AJAX

setup (Verify it is the same with the docs)

# Get Code
git clone https://github.com/yyuu/pyenv.git ~/.pyenv

# Set the Paths
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile

# Initialize pyenv on load of terminal
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

# Restart Shell

commands for just pyenv

# install python
pyenv install 2.7.9
pyenv install 3.4.3

# rehash
pyenv rehash

# set version of python to use for this session
pyenv shell 3.4.3

# set global python for everytime we start pyenv
pyenv global 3.4.3

# set python version for current and all sub directories
pyenv local 3.4.3

pyenv and virtualenv

# Install pyenv virtualenv
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

# auto ativate virtualenv for pyenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile

# restart shell

pyenv virtualenv 1.8-3.4
pyenv deactivate
pyenv virtualenvs
pyenv virtualenv 1.8-2.7
comments powered by Disqus