Why do I receive an ImportError when running one of the CherryPy tutorials

I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9:

$ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/
$ python tut09_files.py
Traceback (most recent call last):
  File "tut09_files.py", line 48, in <module>
    from cherrypy.lib import static
ImportError: cannot import name static

The previous line in the file:

import cherrypy

passes without error, so it appears that it can find cherrypy on the path. What am I missing?

Asked by: Chelsea901 | Posted: 27-01-2022

Answer 1

This works for me, and I'm also using CherryPy 3.1.0, so I'm not sure what to tell you.

Look in your /Library/Python/2.5/site-packages/cherrypy/lib directory for a file named static.py; if this file exists then I'm not sure what to tell you. If it doesn't then something has happened to your CherryPy and I'd advise you to reinstall. If it does then you should check the value of sys.path to make sure it's detecting the right version of CherryPy.

You can also try running the python interpreter on the command line and then doing a from cherrypy.lib import static to see if you get the same result.

Answered by: Blake598 | Posted: 28-02-2022

Answer 2

I had an old CherryPy-2.3.0-py2.5.egg file in my site-packages. After removing the old .egg I could run the tutorial.

Answered by: Agata586 | Posted: 28-02-2022

Similar questions

import - Bizarre python ImportError

Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive. I have two files in a directory of my Mac home directory: foo.py pass test.py import foo If I run test.py from within my virtual machine by typing 'python test.py', I get this...

python - Django ImportError at / no matter what I do

So I've just started playing around with Django and I decided to give it a try on my server. So I installed Django and created a new project, following the basics outlined in the tutorial on Djangoproject.com Unfortunatly, no matter what I do, I can't get views to work: I constantly get ImportError at / No module named index

importerror - unable to import libxml2mod from the python script

File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in &lt;module&gt; import libxml2mod ImportError: /usr/local/lib/python2.5/site-packages/libxml2mod.so: undefined symbol:xmlTextReaderSetup &gt;&gt;&gt; import libxml2mod &gt;&gt;&gt; import libxml2 &gt;&gt;&gt; on Python Prompt it works fine !! can anyone has idea why my program is not working from .py file as i...

python - PyQt 4.7 - ImportError after installing on Windows

I've been trying to install PyQt 4.7 on Vista, but I am getting an ImportError when I try to do: from PyQt4 import QtCore, QtGui. ImportError: DLL load failed: The specified module could not be found. I've checked my System Path, and C:\Python31\Lib\site-packages\PyQt4\bin is on there. I can't run any of the examples, but t...

Python: ImportError no module named urllib

I just rented a VPS from Linode which has python2.5 and ubuntu 8.04. When I run this command from python shell: import urllib I get: ImportError: No module named urllib What can be the reason? How can I add this module to python? Isn't it prepackaged with the basic version? Can it be PYTHONPATH problem?

python - ImportError and Django driving me crazy

OK, I have the following directory structure (it's a django project): -> project --> app and within the app folder, there is a scraper.py file which needs to reference a class defined within models.py I'm trying to do the following: import urllib2 import os import sys import time import datetime import re import BeautifulSoup sys.path.append('/home/userspace/Development/') os...

unix - New at Python: GLPK not building properly / Python ImportError

This is a beginner question, and a follow-up to this one, where I was pointed to GLPK. I'm trying to get PyGLPK, a Python binding for the

python - ImportError using nose, no ImportError using raw unittest?

I get an ImportError when running my unittests using Nose and I don't when I just run it standalone. All files referred to here may be seen at http://gist.github.com/395541# . If I run the test script, importTest-Test.py, directly I get this output: C:\usr\x\data\src\Python\mmm&gt;python importTest-Test....

python - manage.py runserver throws an ImportError with my appname, MacPorts issue on OSX?

I've been developing a Django app for weeks locally on OSX 10.6.3. Recently, I rebooted my machine and went to start my development environment up. Here's the error: cm:myApp cm$ python manage.py runserver Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/init...

python - How to fix ImportError in matplotlib

I compiled matplotlib on a mac running snow leopard only to find that when I import matplotlib.pyplot I get the following error: Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 6, in &lt;module&gt; from matplotlib.figure import Figure, figaspect File "/...

Still can't find your answer? Check out these communities...

PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python