0

I recently found the Twisted python library and was trying to set it up with a test script.

from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor

class Pong(Protocol):
    def connectionMade(self):
        self.transport.write("HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nPong!\r\n")
        self.transport.loseConnection()

# Start the reactor
factory = Factory()
factory.protocol = Pong
reactor.listenTCP(8000, factory)
reactor.run()

When i run the above (I am using python 2.7.9 btw) in Terminal, I get an error. The last line of the error is below. If you need the rest, I can post it as well.

AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1'
ikhaliq15
  • 143
  • 1
  • 12

1 Answers1

1

OP_NO_TLSv1_1 is an attribute in pyOpenSSL. This means your version of pyOpenSSL is too old. pip install -U pyopenssl or pip install twisted[tls] should resolve this, but I'd highly recommend doing all of this in a virtual environment if you aren't already.

Paul Kehrer
  • 13,466
  • 4
  • 40
  • 57
  • What exactly is a virtual environment? How do I set one up? – ikhaliq15 Feb 25 '17 at 00:53
  • http://docs.python-guide.org/en/latest/dev/virtualenvs/ can get you started. There are dozens of other guides out there for various ways to make it easier to use, etc. – Paul Kehrer Feb 25 '17 at 01:04
  • Thank you. The virtual environment made everything work fine and I didn't even need to use the upgrade commands. – ikhaliq15 Feb 25 '17 at 01:10