Forums

Twisted development on paid account?

Hello...I'm attempting to use Python Twisted library under my paid account. While attempting to import twisted I get the below traceback:

09:49 ~/twisted_dev $ python echoserver.py                                                                                                                                                                                                                                      
Traceback (most recent call last):
File "echoserver.py", line 1, in <module>
from twisted.internet import protocol, reactor
File "/usr/local/lib/python2.7/dist-packages/twisted/__init__.py", line 53, in <module>
_checkRequirements()
File "/usr/local/lib/python2.7/dist-packages/twisted/__init__.py", line 37, in _checkRequirements
raise ImportError(required + ": no module named zope.interface.")
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.

Can somone please assist with this? I can see that zope is indeed installed. Thanks.

There is an issue that we're trying to track down that relates to some packages installing a zope.interface that is not compatible with what twisted is looking for (even though the versions seem to be correct) If you want to install twisted, the best way to do it is to use a virtualenv. However, be aware that many of the twisted server-type applications (like the echo server that you seem to be trying to run) will not work from a console (we don't route random network traffic to console servers).

Thanks..can you explain a little more on how I would implement the virtualenv in this case? I followed the virtualenv tutorial listed in several posts here...however I'm unsure how to access twisted and instal zope. I'm unable to install packages so far as I can tell (a call to apt-get doesn't work) also, what other options do I have if I'm unable to use the console?...does this include ssh as well? Thanks.

You use pip to install Python packages into a virtualenv. There is a guide on the wiki for Django and web apps, but the general principles can be followed for non-web app virtualenv.

Perhaps I should have been clearer about the console and twisted servers: Twisted servers that open external ports will run, but there's no way for you to connect to them. The only external traffic that we route into PythonAnywhere is HTTP traffic through the WSGI interface of web apps. If you want to run Twisted code and actually connect to it, you will need to use a WSGI wrapper around it and create it as a web app.

OK...what about running twisted apps with localhost connections for testings? For instance, let's say I want to bind to port 8000 and then use a client app to test connectivity to port 8000..is this permitted? Would I still need to use the virtual environment?

Also...any progress on the zope inteface yet? Thanks agin.

You can run the app with localhost settings to test, but we can only guarantee that you'll be able to access it from test client apps that are run in the same console -- hopefully that's enough to get you going, though!

The problem with zope is likely to take a while to fix. It's an external packaging problem, and it's not immediately obvious how we can fix it right now. The virtualenv solution should work, though.