Ubuntu comes with python installed. To install python on windows, install from the official website to get the latest version. Use the “Windows Installer” link from the home page.
An MSI package is provided for download which is manually installed by double clicking the downloaded file. This installs to a directory with version number embedded in. A 2.6 version will install at C:\python26\. This allows multiple versions of python on the same system.
Add python interpreter to your PATH. Steps:
This opens the System information window.
Click On the “Advanced system settings”. Opens a system properties dialog box
Under the advanced tab, click on the “Environment variables”
Select path variable in the system variables and click on edit
Assuming your installation is in C:\Python26\, add the following to the variable value.
Now the python interpreter is in your PATH.
To ease installation of third party packages, use pip. Download it from here. All packages have a setup.py file which is used in the installation process.
Use the command prompt to install. Change directory to the directory the setup.py file is located and run the installation command “setup.py install”.
This installs pip. Further installations will be done using pip command thus easing the process. Pip command can be run from any directory.
The virtualenv kit provides ability of creating virtual python environments isolating each project from others thus no interference. Each project has its completely unique environment and the required dependencies.
To install, use pip
> pip install virtualenv.
In a new Python environment, change directory to where the environment should be, and run the virtualenv utility in your project’s directory.
I will create a directory C:/tutorial where my environment will be created. Go to that directory on the command prompt.
Run the following command to create the environment.
> virtualenv –distribute venv. (For Ubuntu users add “
--no-site-packages “ )
A copy of pip in the Scripts subdirectory is automatically included in each new environment for easy setup of the third-party libraries and tools to use in that environment.
Activating the environment
run; $ source venv/bin/activate
Windows users run;
This changes the prompt which will include the name of the project. (It is a must to activate the virtual environment for each session you wish to run your application.)
Dependencies Installed using pip:
Use pip to install
$ pip install Django
This downloads and installs the latest django package.
Creating a Django project use:
$ django-admin.py startproject helloworld .
Always use ‘
.’after the command. This tells django to put the project into the current directory which would have instead been put in some other subdirectory.
Test the server if it is working. Run the following command
$ python manage.py runserver
It should run with 0 errors.
Open the browser and visit this url: http://127.0.0.1:8000/
If it has not, something was not done right and you should check where you went wrong.
Designed By: Waleed Rafique
All Rights Reserved, Sharath Reddy