An example of running Django 1.7.4 under Python 3.4.2 on Ubuntu 14.04
Hello.
In this example, I will show one of the ways to run the current version of Django under fresh Python.
Python 3.4.2 | Release Date: 2014-10-13
Django 1.7.4 | January 27, 2015 virtualenvwrapper and pyenv
will be used : - virtualenvwrapper will work with the "system" python2 - we will use pyenv to install the latest version of Python - we will use virtualenvwrapper to create a virtual environment with the latest version of Python "inside"
The launch will be done on Ubuntu 14.04.1 LTS:
After installing Ubuntu, bash is available by default:
Also, by default, 2 versions of Python are immediately preinstalled:
virtualenvwrapper is a convenient wrapper around virtualenv.
To install virtualenvwrapper you need to perform some actions.
Get the new Ubuntu package lists:
Install pip:
Install virtualenvwrapper:
Configure virtualenvwrapper:
Create a folder for PROJECT_HOME from the settings above:
Apply settings:
Now, virtualenvwrapper commands should be available, for example:
pyenv is a handy utility for managing Python versions.
To install pyenv, you need to perform some steps.
Install the necessary dependencies:
Install git:
Install pyenv:
Configure pyenv:
Apply settings:
Now we should have pyenv commands available, for example, you can see the utility version:
pyenv provides the ability to install many different versions of Python.
Install Python 3.4.2:
Run 'rehash' (Rebuild the shim binaries. You should do this any time you install a new Python binary):
To view installed versions of Python, you must do:
Now you can create a virtual environment based on Python 3.4.2.
By default, the Python 3.4.2 binary will be available in '~ / .pyenv / versions /':
We create a virtual environment (and immediately find ourselves “inside” it):
Checking the Python version:
To exit the virtual environment, you must do:
To view all virtual environments, you must do:
You can get "back" into the virtual environment by doing:
To demonstrate the functionality of Django 1.7.4 under Python 3.4.2, run the Django 'polls' app from the Django Tutorial .
I created a repository that contains the executed Django Tutorial and the file 'requirements.txt'.
Let's go to the folder for PROJECT_HOME from the settings above:
We’ll “clone” a repository that contains the executed Django Tutorial:
Let's go to the project folder:
“Fix” the project folder to our virtual environment (upon activation of the environment, we will fall into this folder):
Install Django 1.7.4:
Run the tests:
Run the server for development:
Now you can click on the link
http://127.0.0.1:8000/polls/
and see the results of this example.
For / admin / Username == Password == 'admin'.
Virtual Environments | The Hitchhiker's Guide to Python
virtualenvwrapper | Installation
pyenv | Installation
Blast into PyEnv [September 18, 2014]
Building Python on Ubuntu with pyenv [March 2, 2014]
python Version Manager [November 25, 2013]
Multi-hosting django applications using nginx + uwsgi + virtualenv [May 15, 2013]
Writing your first Django app , part 1
In this example, I will show one of the ways to run the current version of Django under fresh Python.
Python 3.4.2 | Release Date: 2014-10-13
Django 1.7.4 | January 27, 2015 virtualenvwrapper and pyenv
will be used : - virtualenvwrapper will work with the "system" python2 - we will use pyenv to install the latest version of Python - we will use virtualenvwrapper to create a virtual environment with the latest version of Python "inside"
System Information
The launch will be done on Ubuntu 14.04.1 LTS:
devel787@vbox64:~$ uname -a
Linux vbox64 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
devel787@vbox64:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty
After installing Ubuntu, bash is available by default:
devel787@vbox64:~$ echo $SHELL
/bin/bash
devel787@vbox64:~$ bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Also, by default, 2 versions of Python are immediately preinstalled:
devel787@vbox64:~$ python --version
Python 2.7.6
devel787@vbox64:~$ python3 --version
Python 3.4.0
Install virtualenvwrapper
virtualenvwrapper is a convenient wrapper around virtualenv.
To install virtualenvwrapper you need to perform some actions.
Get the new Ubuntu package lists:
devel787@vbox64:~$ sudo apt-get update
Install pip:
devel787@vbox64:~$ sudo apt-get install python-pip
Install virtualenvwrapper:
devel787@vbox64:~$ sudo pip install virtualenvwrapper
Configure virtualenvwrapper:
devel787@vbox64:~$ echo '' >> ~/.bashrc
devel787@vbox64:~$ echo '# virtualenvwrapper' >> ~/.bashrc
devel787@vbox64:~$ echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc
devel787@vbox64:~$ echo 'export PROJECT_HOME=$HOME/vwrapperhome' >> ~/.bashrc
devel787@vbox64:~$ echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc
devel787@vbox64:~$ echo '' >> ~/.bashrc
Create a folder for PROJECT_HOME from the settings above:
devel787@vbox64:~$ mkdir ~/vwrapperhome
Apply settings:
devel787@vbox64:~$ source ~/.bashrc
Now, virtualenvwrapper commands should be available, for example:
devel787@vbox64:~$ workon
devel787@vbox64:~$ virtualenvwrapper
Pyenv installation
pyenv is a handy utility for managing Python versions.
To install pyenv, you need to perform some steps.
Install the necessary dependencies:
devel787@vbox64:~$ sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm
Install git:
devel787@vbox64:~$ sudo apt-get install git
Install pyenv:
devel787@vbox64:~$ cd
devel787@vbox64:~$ git clone git://github.com/yyuu/pyenv.git .pyenv
Configure pyenv:
devel787@vbox64:~$ echo '' >> ~/.bashrc
devel787@vbox64:~$ echo '# pyenv' >> ~/.bashrc
devel787@vbox64:~$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
devel787@vbox64:~$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
devel787@vbox64:~$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
devel787@vbox64:~$ echo '' >> ~/.bashrc
Apply settings:
devel787@vbox64:~$ exec $SHELL
Now we should have pyenv commands available, for example, you can see the utility version:
devel787@vbox64:~$ pyenv --version
pyenv 20150204
Install Python 3.4.2
pyenv provides the ability to install many different versions of Python.
To view all available versions, you must do:
devel787@vbox64:~$ pyenv install --list
Available versions:
2.1.3
2.2.3
2.3.7
2.4
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5
2.5.1
2.5.2
2.5.3
2.5.4
2.5.5
2.5.6
2.6.6
2.6.7
2.6.8
2.6.9
2.7-dev
2.7
2.7.1
2.7.2
2.7.3
2.7.4
2.7.5
2.7.6
2.7.7
2.7.8
2.7.9
3.0.1
3.1-dev
3.1.3
3.1.4
3.1.5
3.2-dev
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.3.0
3.3-dev
3.3.1
3.3.2
3.3.3
3.3.4
3.3.5
3.3.6
3.4.0
3.4-dev
3.4.1
3.4.2
3.5-dev
anaconda-1.4.0
anaconda-1.5.0
anaconda-1.5.1
anaconda-1.6.0
anaconda-1.6.1
anaconda-1.7.0
anaconda-1.8.0
anaconda-1.9.0
anaconda-1.9.1
anaconda-1.9.2
anaconda-2.0.0
anaconda-2.0.1
anaconda-2.1.0
anaconda3-2.0.0
anaconda3-2.0.1
anaconda3-2.1.0
ironpython-dev
ironpython-2.7.4
ironpython-2.7.5
jython-dev
jython-2.5.0
jython-2.5-dev
jython-2.5.1
jython-2.5.2
jython-2.5.3
jython-2.5.4-rc1
jython-2.7-beta1
jython-2.7-beta2
jython-2.7-beta3
miniconda-2.2.2
miniconda-3.0.0
miniconda-3.0.4
miniconda-3.0.5
miniconda-3.3.0
miniconda-3.4.2
miniconda-3.7.0
miniconda3-2.2.2
miniconda3-3.0.0
miniconda3-3.0.4
miniconda3-3.0.5
miniconda3-3.3.0
miniconda3-3.4.2
miniconda3-3.7.0
pypy-c-jit-latest
pypy-c-nojit-latest
pypy-dev
pypy-1.5-src
pypy-1.5
pypy-1.6
pypy-1.7-dev
pypy-1.7
pypy-1.8-dev
pypy-1.8
pypy-1.9-dev
pypy-1.9
pypy-2.0-dev
pypy-2.0-src
pypy-2.0
pypy-2.0.1-src
pypy-2.0.1
pypy-2.0.2-src
pypy-2.0.2
pypy-2.1-src
pypy-2.1
pypy-2.2-src
pypy-2.2
pypy-2.2.1-src
pypy-2.2.1
pypy-2.3-src
pypy-2.3
pypy-2.3.1-src
pypy-2.3.1
pypy-2.4.0-src
pypy-2.4.0
pypy-2.4-beta1-src
pypy-2.4-beta1
pypy-2.5.0-src
pypy-2.5.0
pypy3-dev
pypy3-2.3.1-src
pypy3-2.3.1
pypy3-2.4.0-src
pypy3-2.4.0
stackless-dev
stackless-2.7-dev
stackless-2.7.2
stackless-2.7.3
stackless-2.7.4
stackless-2.7.5
stackless-2.7.6
stackless-2.7.7
stackless-2.7.8
stackless-3.2-dev
stackless-3.2.2
stackless-3.2.5
stackless-3.3-dev
stackless-3.3.5
stackless-3.4.1
Install Python 3.4.2:
devel787@vbox64:~$ pyenv install 3.4.2 -v
Run 'rehash' (Rebuild the shim binaries. You should do this any time you install a new Python binary):
devel787@vbox64:~$ pyenv rehash
To view installed versions of Python, you must do:
devel787@vbox64:~$ pyenv versions
* system (set by /home/devel787/.pyenv/version)
3.4.2
Creating a virtual environment
Now you can create a virtual environment based on Python 3.4.2.
By default, the Python 3.4.2 binary will be available in '~ / .pyenv / versions /':
devel787@vbox64:~$ ls -lahF ~/.pyenv/versions/3.4.2/bin/python
lrwxrwxrwx 1 devel787 devel787 9 Feb 10 16:24 /home/devel787/.pyenv/versions/3.4.2/bin/python -> python3.4*
We create a virtual environment (and immediately find ourselves “inside” it):
devel787@vbox64:~$ mkvirtualenv -p ~/.pyenv/versions/3.4.2/bin/python polls174-py342-venv
Checking the Python version:
(polls174-py342-venv)devel787@vbox64:~$ python --version
Python 3.4.2
To exit the virtual environment, you must do:
(polls174-py342-venv)devel787@vbox64:~$ deactivate
To view all virtual environments, you must do:
devel787@vbox64:~$ workon
polls174-py342-venv
You can get "back" into the virtual environment by doing:
devel787@vbox64:~$ workon polls174-py342-venv
Launch Django 'polls' app
To demonstrate the functionality of Django 1.7.4 under Python 3.4.2, run the Django 'polls' app from the Django Tutorial .
I created a repository that contains the executed Django Tutorial and the file 'requirements.txt'.
Let's go to the folder for PROJECT_HOME from the settings above:
(polls174-py342-venv)devel787@vbox64:~$ cd ~/vwrapperhome/
We’ll “clone” a repository that contains the executed Django Tutorial:
(polls174-py342-venv)devel787@vbox64:~/vwrapperhome$ git clone https://github.com/devel787/polls174.git
Let's go to the project folder:
(polls174-py342-venv)devel787@vbox64:~/vwrapperhome$ cd polls174/
“Fix” the project folder to our virtual environment (upon activation of the environment, we will fall into this folder):
(polls174-py342-venv)devel787@vbox64:~/vwrapperhome/polls174$ setvirtualenvproject
Setting project for polls174-py342-venv to /home/devel787/vwrapperhome/polls174
Install Django 1.7.4:
(polls174-py342-venv)devel787@vbox64:~/vwrapperhome/polls174$ pip install -r requirements.txt
Run the tests:
(polls174-py342-venv)devel787@vbox64:~/vwrapperhome/polls174$ python manage.py test
Run the server for development:
(polls174-py342-venv)devel787@vbox64:~/vwrapperhome/polls174$ python manage.py runserver
Now you can click on the link
http://127.0.0.1:8000/polls/
and see the results of this example.
For / admin / Username == Password == 'admin'.
Literature
Virtual Environments | The Hitchhiker's Guide to Python
virtualenvwrapper | Installation
pyenv | Installation
Blast into PyEnv [September 18, 2014]
Building Python on Ubuntu with pyenv [March 2, 2014]
python Version Manager [November 25, 2013]
Multi-hosting django applications using nginx + uwsgi + virtualenv [May 15, 2013]
Writing your first Django app , part 1