CherryPy 3.2.2: No module named Cookie

2,119 views
Skip to first unread message

T. S. Ferreira

unread,
Jan 24, 2012, 10:53:48 AM1/24/12
to cherryp...@googlegroups.com
I installed Python 3.2.2 and CherryPy 3.2.2 on my Linux machine
(Ubuntu 10.04.3).  When I try to "import cherrypy" I get the output

Traceback (most recent call last):
 File "/usr/local/lib/python3.2/site-packages/cherrypy/_cpcompat.py",
line 203, in <module>
   from Cookie import SimpleCookie, CookieError
ImportError: No module named Cookie

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/local/lib/python3.2/site-packages/cherrypy/__init__.py",
line 62, in <module>
   from cherrypy._cpcompat import urljoin as _urljoin, urlencode as _urlencode
 File "/usr/local/lib/python3.2/site-packages/cherrypy/_cpcompat.py",
line 209, in <module>
   from http.client import BadStatusLine, HTTPConnection,
HTTPSConnection, IncompleteRead, NotConnected
ImportError: cannot import name HTTPSConnection

Some sites suggest that I should install libssl-dev, which I did but
it did not help.

I found that there is a module
/usr/local/lib/python3.2/http/cookies.py (lower case, plural!) which
provides classes "SimpleCookie" and "CookieError".

Any suggestions?

-- tsf

Anders Langworthy

unread,
Jan 24, 2012, 11:16:01 AM1/24/12
to cherryp...@googlegroups.com

Hi.

The Cookie/cookies exception is a red herring, the actual error is the
inability to import HTTPSConnection. Your python doesn't have SSL
support, which probably means you need to install the OpenSSL libraries,
whatever Ubuntu is calling them this week. Installing libssl-dev is a
good guess--did you reboot (or properly rerun ldconfig) after doing
that?

Tsf

unread,
Jan 24, 2012, 12:54:44 PM1/24/12
to cherrypy-users
I don't understand what you mean by "red herring". Anyway, I rebooted
my machine and it still gives the same message :-(.

-- tsf

Eric Larson

unread,
Jan 24, 2012, 1:11:14 PM1/24/12
to cherryp...@googlegroups.com
The "red herring" is that the issue is a cookie problem. Did you compile Python yourself? If not, where did you get the packages? The package might not have been compiled with SSL support.

If you did compile it yourself (on ubuntu for example) you can visit /usr/lib/src/pythonX.X/ after installing the libssl package and rebuild python by running:

sudo python setup.py build
sudo python setup.py install

That will recognize the SSL libraries and properly configure them, which should then make sure you have an HTTPSConnection to import.

Hope that helps!

--
Eric Larson


On Tuesday, January 24, 2012 at 11:54 AM, Tsf wrote:

> I don't understand what you mean by "red herring". Anyway, I rebooted
> my machine and it still gives the same message :-(.
>
> -- tsf
>

> --
> You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
> To post to this group, send email to cherryp...@googlegroups.com (mailto:cherryp...@googlegroups.com).
> To unsubscribe from this group, send email to cherrypy-user...@googlegroups.com (mailto:cherrypy-user...@googlegroups.com).
> For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.

Tsf

unread,
Jan 24, 2012, 3:28:01 PM1/24/12
to cherrypy-users
Yes! It was enough to reinstall Python 3.2.

Thanks a lot,

-- tsf

Tim Roberts

unread,
Jan 24, 2012, 4:08:29 PM1/24/12
to cherryp...@googlegroups.com
Tsf wrote:
> I don't understand what you mean by "red herring". Anyway, I rebooted
> my machine and it still gives the same message :-(.

"Red herring" is a US colloquialism that means "something irrelevant
that distracts you from the real problem." A "red herring" can lead you
on a "wild goose chase". Computer people tend to be particularly
susceptible to red herrings.

A user brings a laptop in for service. He plugs it in and says "Look,
it won't run Excel any more." The technician says "hmm, did you notice
there is smoke coming from the keyboard?" User says "sure, but I need
to run Excel!"

The Excel part is a red herring...

--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Anders Langworthy

unread,
Jan 24, 2012, 4:41:19 PM1/24/12
to cherryp...@googlegroups.com

Thanks Tim. My apologies for the US-centric term. If I may
elaborate...

In this case the Cookie ImportError exception is a "red herring" because
it looks scary and problematic, but actually it is meaningless with
respect to your problem and so only serves as a distraction. It is an
exception that is raised and then silently handled every time you run
CherryPy using Python 3. You only see it in your traceback because it
wasn't fully handled before another exception (the meaningful one) was
raised.

It's all water under the bridge (oops -- there's another one...) now
though, as fortunately you solved your problem.

Cheers!
Anders.

Tsf

unread,
Jan 25, 2012, 7:24:57 AM1/25/12
to cherrypy-users
Thanks for both explanations!

-- tsf

Jason Friedman

unread,
Feb 24, 2012, 9:42:22 PM2/24/12
to cherryp...@googlegroups.com

HTTPSConnection, IncompleteRead, NotConnected
ImportError: cannot import name HTTPSConnection

A post that I found helpful:


 
Reply all
Reply to author
Forward
0 new messages