Installing Python Flask

Hi,

In this blog post, I will show you how to install Flask (A lightweight Python web framework). Let’fs start:

First, you will need to have your own custom Python version installed

1) Login to ssh

2) Execute the following commands:
mkdir ~/dev
cd ~/dev
wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz

Note: You can download any version you want, just make sure to replace each Python-2.6.4 in the commands with the one you need Python-X.X.X

tar -xzvf Python-2.6.4.tgz
cd Python-2.6.4
./configure –prefix=$HOME/dev
make && make install

curl http://peak.telecommunity.com/dist/virtual-python.py | $HOME/dev/bin/python2.6

3) Install easy_install
curl http://peak.telecommunity.com/dist/ez_setup.py | $HOME/bin/python2.6

4) Check your installation
cd ~/bin
ls

If you do not find python2.6 or easy_install then make sure to do:
cp /home/USER_NAME/dev/bin/python2.6 /home/USER_NAME/bin

Note: Make sure to change USER_NAME and replace it with your own cpanel username.
Note: In your python scripts you will change the interpreter to !#/home/user/bin/python

Add the following line to your ~/.bash_profile file:
$PATH=$HOME/bin:$PATH

Compile the changes:
source ~/.bash_profile

You can also create aliases in your .bashrc file:
alias python=’/home/USER_NAME/bin/python’
alias easy_install=’/home/USER_NAME/bin/easy_install2.6′

Note: Make sure to change USER_NAME and replace it with your own cpanel username.

Compile the changes:
source ~/.bashrc

In that way, every time you call those binaries from ssh, they will reference your local installation instead of the server wide version.

Now you need to install pip

/home/USER_NAME/bin/easy_install-2.6 pip

Note: Make sure to change USER_NAME and replace it with your own cpanel username.
Note: easy_install-2.6 name may differ, so you will need to check the right name (you can simply do: ls /home/USER_NAME/bin to get it)

Now to install Flask

pip install Flask

Note: You will get the message: Successfully installed Flask . . .

Looking for quality Python Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , | Posted under 3rd Party Software | RSS 2.0

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 3 = 5

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>