02 May

django and virtualenv on Aptana Studio

Create a folder for storing Virtualenv environments

C:Usersamachefe>mkdir env
C:Usersamachefe>cd env

Create a virtual environment VCMS by running the virtualenv command.
C:>powershell
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
PS C:>
PS C:Usersamachefeenv>virtualenv vcms
New python executable in vcmsScriptspython.exe
Installing setuptools…………….done.
Installing pip……………….done.

In Microsoft Windows, before activating the virtual environment, ensure that the new environment is used by setting the Powershell execution policy
PS C:> Set-ExecutionPolicy RemoteSigned
PS C:> exit

Activate the virtualenv environment just created

PS C:Usersamachefeenv>vcmsScriptsactivate
(vcms) C:Usersamachefeenv>
(vcms) C:Usersamachefeenv>pip list

(vcms) C:Usersamachefeenv>pip show
ERROR: Please provide a package name or names.
(vcms) C:Usersamachefeenv>pip install django
Downloading/unpacking django
  Downloading Django-1.5.1.tar.gz (8.0MB): 8.0MB downloaded
   Running setup.py egg_info for package django

    warning: no previously-included files matching ‘__pycache__’ found under directory ‘*’
    warning: no previously-included files matching ‘*.py[co]’ found under directory ‘*’
Installing collected packages: django
  Running setup.py install for django

    warning: no previously-included files matching ‘__pycache__’ found under directory ‘*’
    warning: no previously-included files matching ‘*.py[co]’ found under directory ‘*’
Successfully installed django
Cleaning up…
Storing complete log in C:Usersamachefepippip.log


(vcms) C:Usersamachefeenv>

(vcms) C:Usersamachefeenv>pip list
Django (1.5.1)
(vcms) C:Usersamachefeenv>

Deactivate after installing

(vcms) C:Usersamachefeenv>deactivate
C:Usersamachefeenv>

Setting up Aptana Studio

One of the best (and free) IDEs for is Aptana Studio. Aptana Studio is a complete environment that includes extensive capabilities to build Ruby and Rails, PHP, and Python applications, along with complete HTML, CSS and JavaScript editing. Aptana is based on Eclipse, and has one of the best python plugin, PyDev.
It has gives you two options for download. You can either install Aptana on top of your pre-existing Eclipse installation (Eclipse Plug-in Version), or install a standalone version of Eclipse with Aptana pre-configured. I prefer the stand alone version

To create a new Django project in Aptana, go to File->New -> Other. Select the PyDev folder, and finally, the PyDev Django Project option, and click next. Give the project a name.

Under the Interpreter, click to configure a new interpreter.

Hit New… Add Name for the interpreter, and specify a path to your newly made virtualenv. Click Ok

manually select the C:Python27Lib folder. Click OK

Click OK, to close the Python interpreter selector and return to the New Project box.

Select the Interpreter you just created in the last step, and Click Next. Complete the Requirement to create a project.
To test the project, Click the Aptana Studio RUN bottom

Aptana Studio Run button

Check if the project was successful from the browser

NB: You can also add a new Python Interpreter from Preferences > PyDev > Interpreter – Python settings.

10 Apr

Installing Django Framework using pip

The recommended way to install Django is with pip. pip is a tool for installing and managing Python packages.
Before installing Django, you need to install pip!

1. Install python
First things first – get Python! You can get the Python 2.7.3 (the current Python 2.x version as of this writing) 32-bit installer from http://python.org/download/.
C:>python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
Type quit() to close the python interpreter
>>>
>>> quit()

NB: Before punning the command, remember to add the python on the windows environment PATH

2. Install Distribute. Distribute is a pre-requisite for pip
Download the distribute_setup.py file to you computer. Click on the file to install Distribute, or run from the command prompt.
C:>python distribute_setup.py
Extracting in c:usersamache~1appdatalocaltemptmpbjtb6b
Now working in c:usersamache~1appdatalocaltemptmpbjtb6bdistribute-0.6.36
Installing Distribute
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at c:python27libsite-packages
Non-egg installation
Moving elements out of the way…
Already patched.
..
Installed c:python27libsite-packagesdistribute-0.6.36-py2.7.egg
Processing dependencies for distribute==0.6.36
Finished processing dependencies for distribute==0.6.36
After install bootstrap.
C:Python27Libsite-packagessetuptools-0.6c11-py2.7.egg-info already exists

3. Install pip
Now, Download the pip install script from GitHub.
Install by clicking the script or running from python command prompt

C:>python get-pip.py
Downloading/unpacking pip
  Downloading pip-1.3.1.tar.gz (247Kb): 247Kb downloaded
  Running setup.py egg_info for package pip

    warning: no files found matching ‘*.html’ under directory ‘docs’
    warning: no previously-included files matching ‘*.txt’ found under directory
 ‘docs_build’
    no previously-included directories found matching ‘docs_build_sources’
Installing collected packages: pip
  Running setup.py install for pip

    warning: no files found matching ‘*.html’ under directory ‘docs’
    warning: no previously-included files matching ‘*.txt’ found under directory
 ‘docs_build’
    no previously-included directories found matching ‘docs_build_sources’
    Installing pip-script.py script to C:Python27Scripts
    Installing pip.exe script to C:Python27Scripts
    Installing pip-2.7-script.py script to C:Python27Scripts
    Installing pip-2.7.exe script to C:Python27Scripts
Successfully installed pip
Cleaning up…

Test the installation
C:>pip

Usage:
  pip <command> [options]

4. Install virtualenv (Not Compulsory, but very advised)
C:>pip install virtualenv
Install virtualenvwrapper  (for microsoft Windows)
C:>pip install virtualenvwrapper-win

And you are good to go!!

Thanks to tyler butler for his informative procedure