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!
Great article. I got this working pretty quickly with little knowledge of installing and configuring Python. Two points where I had some difficulty:
1. I had to run cp to copy python into /home/USERNAME/bin before I could install easy_install.
2. The name of easy_install-2.6 is listed as easy_install2.6 in the aliases creation step, but everywhere it is (correctly) listed as easy_install-2.6.
Thanks for this article!
I am hung up at the pip install. The process runs and looks successful to me, but then when I try to run ‘pip install Flask’ it says there is no pip command found. So I tried to use ‘easy_install Flask’ and the process ran successfully, but I can’t import the library. What am I doing wrong?
Hi, please contact our support team (support@arvixe.com) and they will be able to assist you.
If you’re a newbie on linux (like me) the command for
“Add the following line to your ~/.bash_profile file: $PATH=$HOME/bin:$PATH”
is ‘vi .bash_profile’. An editor will open, press ‘i’ to be able to type and add the line. To exit the editor press ‘escape’ and then type ‘:wq’ and ‘enter’.
Hi,
At the “./configure” step, I get the following error:
no acceptable C compiler found in $PATH
Is a C compiler unavailable to some shell accounts?
Regards,
Michael.
Should I expect this to work on a PersonalClassPro hosting account?