Prepare your python environment

In the following blog, i’ll shared the basic knowledge of getting started install python, environment setup. Easy_install and Virtual environment preparation.

Setting up environment in window XP

  1. Go to Control Panel > System > [Tab] Advance > [Button] Environment Variables
  2. From the system variables, click "New" button.
  3. Enter "PYTHON26" as variable name.
  4. Enter "C:\Python26\python.exe" as variable value (base on ur installation path). Click Ok to close the window.
  5. From the system variables, find the "PATH" and click edit
  6. Move your cursor to the end, append the ";" and,
  7. Append the "C:\Python26;" right after the ";"
  8. Append the "C:\Python26\scripts;" right after the step 7.


Easy Install

1) If you are from java background, easy_install is library management framework like (maven).
2) Download “easy_install” tools from here. (double click and install)
3) By default, “easy_install” will create a folder called “Script” inside C:\python26\
4) Add additional “C:\Python26\Script;” into the system path (optional for virtual_environment)
More example: Part 1, and part 2


Virtualenv

Install the “virtualenv” run command:

  1. C:\> easy_install virtualenv

Create the virtualenv folder, (you cannot relocated this folder later, extra step is needed)

  1. C:\python-workspace
  2. run command C:\python-workspace>virtualenv virtual_env

Start run ur environment, go to

  1. C:\python-workspace\virtual_env\scripts>active.bat — OR deactivate –
  2. C:\python-workspace\virtual_env\scripts>deactive.bat

Once u had activate the virtual environment, your command prompt should append (virtual_env) this in front.

  1. (virtual_env) C:\python-workspace\virtual_env\Scripts>python

Once your start work on your new created python virtual environment, “easy_install” new library wont be shared with the parent python C:\python26. For instance, from your command prompt, we install python test library ‘nose’

  1. (virtual_env) C:\python-workspace\virtual_env\Scripts>easy_install nose

How to prove it? from your command prompt, type ‘python’ to enter program mode, then ‘import nose’. It should give u no error.

Open another command prompt, type python. and type the same command ‘import nose’. It should give u error No module named nose.

Yeah, for the first step we had finnish setup the environment. We will come back later to install the require libs.

Done!

Back to test-automation contents.

You can leave a response, or trackback from your own site.

Leave a Reply

Security Code: