paster serve -> No module named config.middleware

291 views
Skip to first unread message

JohnWShipman

unread,
Apr 19, 2010, 7:05:45 PM4/19/10
to pylons-discuss
I'm a complete beginner following the steps in _The Definitive Guide
To Pylons.
The 'paster create' command worked with no apparent problems. But
this
command:

paster serve --reload development.ini

gets a stack traceback that ends like this:

File "/u/john/tcc/mylons/root/lib/python2.6/site-packages/
PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line
561, in get_context object_type, name=name)
File "/u/john/tcc/mylons/root/lib/python2.6/site-packages/
PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line
587, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/u/john/tcc/mylons/root/lib/python2.6/site-packages/
setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 1913,
in load
ImportError: No module named config.middleware

Where do I go from here? There is a file config/middleware.py.
I haven't touched any file since the 'paster serve'.

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.

Mike Orr

unread,
Apr 20, 2010, 10:19:33 AM4/20/10
to pylons-...@googlegroups.com
On Mon, Apr 19, 2010 at 4:05 PM, JohnWShipman <jo...@nmt.edu> wrote:
> I'm a complete beginner following the steps in _The Definitive Guide
> To Pylons.
> The 'paster create' command worked with no apparent problems.  But
> this
> command:
>
>    paster serve --reload development.ini
>
> gets a stack traceback that ends like this:
>
>  File "/u/john/tcc/mylons/root/lib/python2.6/site-packages/
>     PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line
>     561, in get_context object_type, name=name)
>  File "/u/john/tcc/mylons/root/lib/python2.6/site-packages/
>     PasteDeploy-1.3.3-py2.6.egg/paste/deploy/loadwsgi.py", line
>     587, in find_egg_entry_point
>    possible.append((entry.load(), protocol, entry.name))
>  File "/u/john/tcc/mylons/root/lib/python2.6/site-packages/
>      setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 1913,
>      in load
> ImportError: No module named config.middleware
>
> Where do I go from here?  There is a file config/middleware.py.
> I haven't touched any file since the 'paster serve'.

Setuptools/pkg_resources is fragile in the sense that the Python path
can get out of whack in several ways and cause an import error. They
are all specific to the particular installation environment, so it can
take some time to track down. It doesn't help that the exception
doesn't say who's asking for it. The 'config.middleware' could be
referring to something in Pylons or Paste.

Does it work without the --reload?

What if you recreate the environment (the virtualenv, if you're using it)?

Did you install the application before running it? ("python setup.py
develop"). I'm not sure if it's strictly necessary, but it will
update the egg-info files, which are what pkg_resources use and can
cause ImportError if they're not up to date.

Which OS and Python version are you using? How did you install Pylons?
Did you create a virtualenv and if so, how? You said you're following
the Pylons book, but I don't remember which approach it uses.

--
Mike Orr <slugg...@gmail.com>

JohnWShipman

unread,
Apr 20, 2010, 1:24:08 PM4/20/10
to pylons-discuss
Here's what I did (in bash); answers to Mike Orr's questions below.
1. python virtualenv.py --no-site-packages root
2. cd root
3. source bin/activate
4. root/bin/easy_install Pylons
This got me version 0.9.6.2.
5. paster create --template=Pylons Site
6. cd Site
7. paster serve development.ini

On Apr 20, 8:19 am, Mike Orr <sluggos...@gmail.com> wrote:

> Setuptools/pkg_resources is fragile in the sense that the Python path
> can get out of whack in several ways and cause an import error. They
> are all specific to the particular installation environment, so it can
> take some time to track down. It doesn't help that the exception
> doesn't say who's asking for it. The 'config.middleware' could be
> referring to something in Pylons or Paste.
>
> Does it work without the --reload?

Without --reload, it's the same failure.

> What if you recreate the environment (the virtualenv, if you're using it)?

I had an old virtual environment from Feb. 20, so I recreated it
just yesterday.

> Did you install the application before running it? ("python setup.py
> develop").  I'm not sure if it's strictly necessary, but it will
> update the egg-info files, which are what pkg_resources use and can
> cause ImportError if they're not up to date.

I don't recall the book saying to do that, but I did it, and it
worked, but
it didn't help.

> Which OS and Python version are you using? How did you install Pylons?

See above for the install. Base OS is Fedora Core 11.

Best regards,
JohnWShipman <jo...@nmt.edu>

John W. Shipman

unread,
Apr 20, 2010, 3:40:58 PM4/20/10
to pylons-...@googlegroups.com
On Tue, 20 Apr 2010, Mike Orr wrote:

>>  6. cd Site
>>  7. paster serve development.ini
>
> OK, the problem is the project name 'Site'. You can't create a project
> with the same name as a standard Python module. I have only seen it
> with 'Test', but it looks like 'Site' has the same problem.
>
> The problem is that with a name like 'Test', Paster naively creates a
> package named 'test'. Then when "paster serve" imports it, it gets
> the stdlib module instead, which of course doesn't contain
> "config.middleware".
>
> The name 'Site' has an additional level of confusion because the
> virtualenv defines its own 'site.py'.
>
> If the book actually has a project named 'Site', I can forward a bug
> to the author.

No, that was my fault.

Thanks very much for your quick diagnosis---I had *no* idea where
to start on this one!

Best regards,
John Shipman (jo...@nmt.edu), Applications Specialist, NM Tech Computer Center,
Speare 119, Socorro, NM 87801, (575) 835-5735, http://www.nmt.edu/~john
``Let's go outside and commiserate with nature.'' --Dave Farber

Mike Orr

unread,
Apr 20, 2010, 2:40:20 PM4/20/10
to pylons-...@googlegroups.com
OK, solution at bottom.

On Tue, Apr 20, 2010 at 10:24 AM, JohnWShipman <jo...@nmt.edu> wrote:
> Here's what I did (in bash); answers to Mike Orr's questions below.
>  1. python virtualenv.py --no-site-packages root
>  2. cd root
>  3. source bin/activate
>  4. root/bin/easy_install Pylons
>        This got me version 0.9.6.2.

Yikes, that's old. The book was written for 0.9.7, and the current
version on PyPI is 0.10rc1. But the steps are still the same for all
these versions.

>  5. paster create --template=Pylons Site

I assume you mean a lowercase 'pylons'. My version of Paster does not
even recognize Pylons with a capital p.

>  6. cd Site
>  7. paster serve development.ini

OK, the problem is the project name 'Site'. You can't create a project
with the same name as a standard Python module. I have only seen it
with 'Test', but it looks like 'Site' has the same problem.

The problem is that with a name like 'Test', Paster naively creates a
package named 'test'. Then when "paster serve" imports it, it gets
the stdlib module instead, which of course doesn't contain
"config.middleware".

The name 'Site' has an additional level of confusion because the
virtualenv defines its own 'site.py'.

If the book actually has a project named 'Site', I can forward a bug
to the author.

--
Mike Orr <slugg...@gmail.com>
Reply all
Reply to author
Forward
0 new messages