QA/Execution/Web Testing/Automation/Virtual Environments: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 19: Line 19:
<i>Exception: use 32-bit version of the setuptools even if your operating system is 64-bit otherwise it fails to find the Python installation.</i>
<i>Exception: use 32-bit version of the setuptools even if your operating system is 64-bit otherwise it fails to find the Python installation.</i>
<ol>
<ol>
     <li>Install the 32-bit version of SetupTools using the provided <b>.exe installer</b>:</li>
     <li>Install the 32-bit version of SetupTools using the provided .exe installer:</li>
     http://pypi.python.org/pypi/setuptools#files
     http://pypi.python.org/pypi/setuptools#files
     <li>Download the last pip version and uncompress it:</li>
     <li>Download the last pip version and uncompress it:</li>
     http://pypi.python.org/pypi/pip#downloads
     http://pypi.python.org/pypi/pip#downloads
     <li>In your <b><i>cmd prompt</i></b>, go to the uncompressed pip directory and run:</li>
     <li>In your cmd prompt, go to the uncompressed pip directory and run:</li>
     python setup.py install
     python setup.py install
     <li>Add the Scripts directory to your System Variables path:</li>
     <li>Add the Scripts directory to your System Variables path:</li>
Line 31: Line 31:
=== Virtualenvwrapper Installation and Usage ===
=== Virtualenvwrapper Installation and Usage ===
<ol>
<ol>
     <li>From the <b><i>cmd prompt</i></b> install <b><i>pip</i></b>:</li>
     <li>From the cmd prompt install pip:</li>
     pip install virtualenvwrapper-win
     pip install virtualenvwrapper-win
     <li>Set your environment variable:</li>
     <li>Set your environment variable:</li>
     WORKON_HOME = C:\Python27\Scripts:
     WORKON_HOME = C:\Python27\Scripts:
     <li>You can now create <b><i>virtualenvs</i></b>:</li>
     <li>You can now create virtualenvs:</li>
     mkvirtualenv <<i>name of the environment</i>>
     mkvirtualenv <<i>name of the environment</i>>
</ol>
</ol>

Revision as of 21:54, 26 October 2012

Virtual environments are isolated Python environments. They allow freedom to install specific versions of dependencies without affecting the global site-packages. They also make it easy to throw away a 'broken' environment and start again. If you need further information regarding virtual environments, please see the virtualenvwrapper documentation.

Install virtualenvwrapper

  1. Install virtualenvwrapper:
  2. sudo pip install virtualenvwrapper
  3. Add the following to your ~/.bash_profile:
  4. export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh

Create a virtual environment for WebQA

   mkvirtualenv webqa

Switch to the WebQA virtual environment

   workon webqa

Installation on Windows

Exception: use 32-bit version of the setuptools even if your operating system is 64-bit otherwise it fails to find the Python installation.

  1. Install the 32-bit version of SetupTools using the provided .exe installer:
  2. http://pypi.python.org/pypi/setuptools#files
  3. Download the last pip version and uncompress it:
  4. http://pypi.python.org/pypi/pip#downloads
  5. In your cmd prompt, go to the uncompressed pip directory and run:
  6. python setup.py install
  7. Add the Scripts directory to your System Variables path:
  8. C:\Python26\Scripts
  9. Now you can use the command pip install package on Win.

Virtualenvwrapper Installation and Usage

  1. From the cmd prompt install pip:
  2. pip install virtualenvwrapper-win
  3. Set your environment variable:
  4. WORKON_HOME = C:\Python27\Scripts:
  5. You can now create virtualenvs:
  6. mkvirtualenv <name of the environment>