1 (edited by mox 2012-01-27 02:01:13)

Topic: ImportError: No module named web

Getting the error from the Subject in my ssl_error_log.  Followed install instructions to the letter, although changed location to /opt/dbmailadmin due to local site requirements.  All installation requirements met.

- Linux/BSD distribution name and version: CentOS release 5.7 (Final)
- iRedMail version and backend (LDAP/MySQL): DBMailAdmin-MySQL-1.0
- Any related log? Log is helpful for troubleshooting.

From my /var/log/httpd/ssl_error_log:

----------------
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x] mod_wsgi (pid=16404): Target WSGI script '/opt/dbmailadmin/dbmailadmin.py' cannot be loaded as Python module.
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x] mod_wsgi (pid=16404): Exception occurred processing WSGI script '/opt/dbmailadmin/dbmailadmin.py'.
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x] Traceback (most recent call last):
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x]   File "/opt/dbmailadmin/dbmailadmin.py", line 8, in <module>
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x]     from libs import iredbase
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x]   File "/opt/dbmailadmin/libs/iredbase.py", line 7, in <module>
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x]     import web
[Thu Jan 26 10:33:59 2012] [error] [client x.x.x.x] ImportError: No module named web
----------------

Not a Python programmer, so I'm probably missing something simple? (I hope!)

Thanks in advance for any help.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: ImportError: No module named web

It requires Python module web.py. You can fix it with below command:

# yun install python-setuptools
# easy_install web.py

Restarting Apache is recommended.

3

Re: ImportError: No module named web

Thanks for the response.  I do have the Python module web.py installed.  I have everything installed that's listed in the requirements.  Here's what I have:

# rpm -q python-webpy
python-webpy-0.35-1

Anyway...I removed this RPM, and followed your adivce:

# yum install python-setuptools
#easy_install web.py

Output from the easy_install command:

---------------------------------------------------------------

Searching for web.py
Reading http://cheeseshop.python.org/pypi/web.py/
Reading http://webpy.org/
Reading http://cheeseshop.python.org/pypi/web.py/0.36
Best match: web.py 0.36
Downloading http://pypi.python.org/packages/source/ … 1f0e024d00
Processing web.py-0.36.tar.gz
Running web.py-0.36/setup.py -q bdist_egg --dist-dir /tmp/easy_install-5BuVyY/web.py-0.36/egg-dist-tmp-B5bkHF
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1670, in main
    with_ei_usage(lambda:
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1659, in with_ei_usage
    return f()
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 1674, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/lib/python2.4/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 211, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 446, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 471, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 655, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 930, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python2.4/site-packages/setuptools/command/easy_install.py", line 919, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 26, in run_setup
    DirectorySandbox(setup_dir).run(
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 63, in run
    return func()
  File "/usr/lib/python2.4/site-packages/setuptools/sandbox.py", line 29, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 6, in ?
  File "/tmp/easy_install-5BuVyY/web.py-0.36/web/__init__.py", line 27, in ?
  File "/tmp/easy_install-5BuVyY/web.py-0.36/web/application.py", line 639
    SUFFIX = '$py.class' if sys.platform.startswith('java') else '.pyc'

---------------------------------------------------------------

Again, not a programmer, so I'm not really sure what I'm seeing here...apologies if I'm being clueless in the Python arena.

4

Re: ImportError: No module named web

Then please install web.py with RPM binary package instead.
Not sure why it doesn't work, could you please try running DBMailAdmin this way:

# cd /opt/dbmailadmin/
# python dbmailadmin.py

If it works well, it will start listening on port 8080, try accessing it from web browser: http://your_server:8080/

Another way is, download web.py source code, then copy it to root directory of DBMailAdmin:

# wget http://webpy.org/static/web.py-0.36.tar.gz
# tar zxf web.py-0.36.tar.gz
# cd web.py-0.36
# cp -rf web /opt/dbmailadmin/

Now open file /opt/dbmailadmin/web/application.py, find line 639:

    SUFFIX = '$py.class' if sys.platform.startswith('java') else '.pyc'

Comment out this line and make it work with Python-2.4:

    #SUFFIX = '$py.class' if sys.platform.startswith('java') else '.pyc'
    if sys.platform.startswith('java'):                                                                                 
        SUFFIX = '$py.class'
    else:
        SUFFIX = '.pyc'

Now try accessing it via Apache web server: https://yourserver/dbmailadmin/