Search code examples
pythonweb-servicescherrypy

AttributeError: 'module' object has no attribute 'url'


I am trying to run dripls and when I install everything including fabric, apache2 and setup appropriate configuration files

I have the following problem

AttributeError: 'module' object has no attribute 'url'

its from the package cherrypy

On this line

app = {
  'root_url': cherrypy.url()
}

Could anyone point out what might be the problem?

**Update: **

Problematic script (full)

import cherrypy
import urlparse
import uuid
import os

    # Service
socket = '0.0.0.0'
dripls_main_site_port = 8080
thread_pool = 10

bin_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))), "bin")
pidfile = os.path.join(bin_path, "dripls.pid")
error_log = os.path.join(bin_path, "error_log.log")
access_log = os.path.join(bin_path, "access_log.log")

app = {
  'root_url': cherrypy.url()
}

# Shaper path
shaper_path = os.path.join(bin_path, "set_ts_lo.sh")

# Shape port range 
shape_start_port = 10000
shape_end_port = 11000

# Environment overrides
if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "env.py")):
    from env import *
else:
    from local import *

port = int(dripls_main_site_port)

# Final url rewrite. Hack to battle the fact that cherrypy is behind a proxy on different port  
def get_final_url(path, args):
    cherrypy_url = cherrypy.url(path, args)

    scheme, netloc, path, qs, anchor = urlparse.urlsplit(cherrypy_url)
    return urlparse.urlunsplit( (scheme, urlparse.urlsplit(app['root_url'])[1], path, qs, anchor))

def get_seeded_cid(cid):
    return "{0}_{1}".format(cid, uuid.uuid4().hex)"

Update :

Python 2.7.3 (default, Apr 10 2013, 05:46:21) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cherrypy 
>>> cherrypy.url
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'url'
>>> print cherrypy.__file__
/usr/lib/pymodules/python2.7/cherrypy/__init__.pyc
>>> 

Solution

  • Sorry but I found out the problem.

    It did not work if you install cherrypy using

    sudo apt-get install python-cherrypy
    

    You have install pip using

    sudo apt-get install python-pip 
    

    and then

    sudo pip install CherryPy