Pre req:
I am using ubuntu 10.10 for this tutorial.
1) Install python
Using below command you can install python, I will install components like pip, virtualenv along with python.
Open terminal and past below code:
sudo apt-get install python-pip python-dev build-essential
# Check version of python
python --version
# Upgrade tools:
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
Open terminal and past below code:
sudo apt-get install python-pip python-dev build-essential
# Check version of python
python --version
# Upgrade tools:
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
2) Create a virtual environment and setup project
#Create a folder
mkdir pywork
cd pywork
mkdir hellopy
cd hellopy
# Create virtual environment for this project.
virtualenv venv_hello (you can use any name)
cd venv_hello
mkdir pywork
cd pywork
mkdir hellopy
cd hellopy
# Create virtual environment for this project.
virtualenv venv_hello (you can use any name)
cd venv_hello
3) Create and execute a file (py)
Create a file lest say t.py. You can add code like
def test():
print("Hello python")
test();
to execute file use command in terminal
python t.py
References:
# http://www.saltycrane.com/blog/2010/02/how-install-pip-ubuntu/
# http://docs.python-guide.org/en/latest/dev/virtualenvs/
# http://stackoverflow.com/questions/1522564/how-do-i-run-a-python-program
# http://docs.python-guide.org/en/latest/dev/virtualenvs/
No comments:
Post a Comment