CherryPy comes in packages like most open-source projects, which can be downloaded and installed in various ways which are mentioned as follows −
The basic requirements for installation of CherryPy framework include −
Installing 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 −
/usr/local/lib/python2.4/site-packages or /usr/lib/python2.4/site-packages
C:\Python or C:\Python2x
Python:Lib:site-package
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 library. The name comes from the utility 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 utility 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
Python Enterprise Application Kit (PEAK) provides a python module named Easy Install. This facilitates deployment of the Python packages. This module simplifies the procedure of downloading, building and deploying Python application and products.
Easy Install needs to be installed in the system before installing 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 centralized 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 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.
It needs to be verified whether the application has properly been installed in the system or not in the same way as we do for applications like 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>", line 1, in ? ImportError: No module named cherrypy