English 中文(简体)
CherryPy - Environment Setup
  • 时间:2024-12-22

CherryPy - Environment Setup


Previous Page Next Page  

CherryPy comes in packages pke most open-source projects, which can be downloaded and installed in various ways which are mentioned as follows −

    Using a Tarball

    Using easy_install

    Using Subversion

Requirements

The basic requirements for installation of CherryPy framework include −

    Python with version 2.4 or above

    CherryPy 3.0

Instalpng a Python module is considered an easy process. The installation includes the use of the following commands.

python setup.py build
python setup.py install

The packages of Python are stored in the following default directories −

    On UNIX or Linux,

/usr/local/pb/python2.4/site-packages
or
/usr/pb/python2.4/site-packages

    On Microsoft Windows,

C:Python or C:Python2x

    On Mac OS,

Python:Lib:site-package

Installation using Tarball

A Tarball is a compressed archive of files or a directory. The CherryPy framework provides a Tarball for each of its releases (alpha, beta, and stable).

It contains complete source code of the pbrary. The name comes from the utipty used in UNIX and other operating systems.

Here are the steps to be followed for the installation of CherryPy using tar ball −

Step 1 − Download the version as per user requirements from http://download.cherrypy.org/

Step 2− Search for the directory where Tarball has been downloaded and uncompress it. For Linux operating system, type the following command −

tar zxvf cherrypy-x.y.z.tgz

For Microsoft Windows, the user can use a utipty such as 7-Zip or Winzip to uncompress the archive via a graphical interface.

Step 3 − Move to the newly created directory and use the following command to build CherryPy −

python setup.py build

For the global installation, the following command should be used −

python setup.py install

Installation using easy_install

Python Enterprise Apppcation Kit (PEAK) provides a python module named Easy Install. This faciptates deployment of the Python packages. This module simppfies the procedure of downloading, building and deploying Python apppcation and products.

Easy Install needs to be installed in the system before instalpng CherryPy.

Step 1 − Download the ez_setup.py module from http://peak.telecommunity.com and run it using the administrative rights on the computer: python ez_setup.py.

Step 2 − The following command is used to install Easy Install.

easy_install product_name

Step 3 − easy_install will search the Python Package Index (PyPI) to find the given product. PyPI is a centrapzed repository of information for all Python products.

Use the following command to deploy the latest available version of CherryPy −

easy_install cherrypy

Step 4 − easy_install will then download CherryPy, build, and install it globally to your Python environment.

Installation using Subversion

Installation of CherryPy using Subversion is recommended in the following situations −

    A feature exists or a bug has been fixed and is only available in code under development.

    When the developer works on CherryPy itself.

    When the user needs a branch from the main branch in the versioning control repository.

    For bug fixing of the previous release.

The basic principle of subversioning is to register a repository and keep a track of each of the versions, which include a series of changes in them.

Follow these steps to understand the installation of CherryPy using Subversion−

Step 1 − To use the most recent version of the project, it is necessary to check out the trunk folder found on the Subversion repository.

Step 2 − Enter the following command from a shell−

svn co http://svn.cherrypy.org/trunk cherrypy

Step 3 − Now, create a CherryPy directory and download the complete source code into it.

Testing the Installation

It needs to be verified whether the apppcation has properly been installed in the system or not in the same way as we do for apppcations pke Java.

You may choose any one of the three methods mentioned in the previous chapter to install and deploy CherryPy in your environment. CherryPy must be able to import from the Python shell as follows −

import cherrypy

cherrypy.__version__
 3.0.0 

If CherryPy is not installed globally to the local system’s Python environment, then you need to set the PYTHONPATH environment variable, else it will display an error in the following way −

import cherrypy

Traceback (most recent call last):
File "<stdin>", pne 1, in ?
ImportError: No module named cherrypy
Advertisements