I'm a programmer, but I'm not a Python programmer, yet. So I'm sure what I'm doing wrong here relates more to my lack of knowledge than anything else...
I'm looking at a Websockets example here: http://eventlet.net/doc/examples.html#websocket-server-example
On my Ubuntu system I have tried: sudo apt-get install python-eventlet (which installs Eventlet 0.12.1, which appears to be the current version)
I then try to run the example and get: $python eventlet.py Traceback (most recent call last): File "eventlet.py", line 1, in <module> import eventlet File "/home/mark/python/eventlet.py", line 4, in <module> from eventlet import wsgi ImportError: cannot import name wsgi
If I Google the error, using the assumption that stupid errors are made by lots of people so I won't be alone, I find only two hits neither of which are remotely related. But I've tried this on more than one system without success.
Suggestions?
I don't have the relevant build tools installed to try using easy_install instead but as 0.12.1 is the latest version I don't think the install method is the problem here?
On Tue, Mar 26, 2013 at 12:44:57PM +0000, Mark Rogers wrote:
I'm a programmer, but I'm not a Python programmer, yet. So I'm sure what I'm doing wrong here relates more to my lack of knowledge than anything else...
I'm looking at a Websockets example here: http://eventlet.net/doc/examples.html#websocket-server-example
On my Ubuntu system I have tried: sudo apt-get install python-eventlet (which installs Eventlet 0.12.1, which appears to be the current version)
That's a bit odd! What version of Ubuntu are you running? I'm running Xubuntu 12.10 (uses the same repositories as Ubuntu 12.10) and I get python-eventlet version 0.9.17 which seems a lot older.
I have just installed python-eventlet on my system and the example above runs fine.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 03/26/13 12:44, Mark Rogers wrote:
I'm a programmer, but I'm not a Python programmer, yet. So I'm sure
File "/home/mark/python/eventlet.py", line 4, in <module> from eventlet import wsgi ImportError: cannot import name wsgi
Looks like eventlet requires wsgi but the debian package failed at marking that dependency.
I'm not a debianite so can't check but I'd guess you probably want to `apt-get install python-wsgi` or something like that.
Steve
On 26 Mar 12:44, Mark Rogers wrote:
I'm a programmer, but I'm not a Python programmer, yet. So I'm sure what I'm doing wrong here relates more to my lack of knowledge than anything else...
I'm looking at a Websockets example here: http://eventlet.net/doc/examples.html#websocket-server-example
On my Ubuntu system I have tried: sudo apt-get install python-eventlet (which installs Eventlet 0.12.1, which appears to be the current version)
I then try to run the example and get: $python eventlet.py Traceback (most recent call last): File "eventlet.py", line 1, in <module> import eventlet File "/home/mark/python/eventlet.py", line 4, in <module> from eventlet import wsgi ImportError: cannot import name wsgi
Right - so you've named your local script "eventlet.py"? Erm, well, that's going to then be the "eventlet" namespace, and so you've broken yourself straight off...
So, rename "eventlet.py" to "eventlet-test.py" or similar and try again.
Cheers,
On 03/26/13 13:36, Brett Parker wrote:
Right - so you've named your local script "eventlet.py"? Erm, well, that's going to then be the "eventlet" namespace, and so you've broken yourself straight off...
So, rename "eventlet.py" to "eventlet-test.py" or similar and try again.
What Brett said :)
On 26 March 2013 13:36, Brett Parker iDunno@sommitrealweird.co.uk wrote:
Right - so you've named your local script "eventlet.py"? Erm, well, that's going to then be the "eventlet" namespace, and so you've broken yourself straight off...
Told you it was probably a stupid error. However, although I started with eventlet.py as my script I had already tried a different example as eventlet2.py with the same results. I've just renamed to eventlet-test.py with the following results:
$ python eventlet-test.py Traceback (most recent call last): File "eventlet-test.py", line 4, in <module> import eventlet File "/home/mark/Dropbox/Projects/Python/eventlet.py", line 5, in <module> ImportError: cannot import name wsgi
(Paths slightly different this time as test was on a different PC.)
I'm confused as /home/mark/Dropbox/Projects/Python/eventlet.py doesn't exist (not any more, anyway).
On 26 March 2013 14:05, Mark Rogers mark@quarella.co.uk wrote:
I'm confused as /home/mark/Dropbox/Projects/Python/eventlet.py doesn't exist (not any more, anyway).
.. but eventlet.pyc does exist, which I assume is the compiled version of the same thing and hence the problem. Removing it solved the problem.
Thanks for the help!
From this I learn that the include path for import includes the
current directory....
On 26 March 2013 14:09, Steve Engledow steve@offend.me.uk wrote:
Is there a /home/mark/Dropbox/Projects/Python/eventlet.pyc by any chance?
Thanks but I worked out just before you told me, so that counts as progress, right??
OK, so I'm now using the examples exactly as provided now that I've found them in /usr/share/doc/python-eventlet/examples
Still running the same example (now called websocket_chat.py), it correctly runs and when I connect with my browser it serves websocket_chat.html to it, which then prompts the browser to attempt to open a websocket. This seems to be generating an error, as reported by the python script:
------------------------ $ python websocket_chat.py
Visit http://localhost:7000/ in your websocket-capable browser.
(26573) wsgi starting up on http://127.0.0.1:7000/ (26573) accepted ('127.0.0.1', 49733) 127.0.0.1 - - [26/Mar/2013 14:25:59] "GET / HTTP/1.1" 200 940 0.000161 (26573) accepted ('127.0.0.1', 49735) 127.0.0.1 - - [26/Mar/2013 14:25:59] "GET /favicon.ico HTTP/1.1" 200 940 0.000210 127.0.0.1 - - [26/Mar/2013 14:25:59] "GET /chat HTTP/1.1" 400 103 0.000094 ------------------------
Note the 400 response which I assume in this context is an error, at "return handle(environ, start_response)". Certainly the chat doesn't seem to work. Again I've tried this on a couple of PCs so is this something equally daft on my part or do I need to dig deeper this time?
On 26 March 2013 14:35, Mark Rogers mark@quarella.co.uk wrote:
Note the 400 response which I assume in this context is an error, at "return handle(environ, start_response)".
I think I have got to the bottom of this, in case anyone else is interested: I think it's a discrepancy between the version of Websockets that the browsers talk and the one implemented in the Python library, so not an error in what I'm doing but just an indication I should try a different library.