0

I have a flask app wrapped in a tornado server and I was trying to run app on a remote server when I got this error:

Traceback (most recent call last):
  File "run.py", line 7, in <module>
    server.listen(80)
  File "/home/ec2-user/gatekeeper/local/lib/python2.7/site-packages/tornado/tcpserver.py", line 126, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/ec2-user/gatekeeper/local/lib/python2.7/site-packages/tornado/netutil.py", line 187, in bind_sockets
    sock.bind(sockaddr)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 13] Permission denied

So I tried to use sudo and I got this:

Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from tornado.wsgi import WSGIContainer
ImportError: No module named tornado.wsgi

So I am wondering if I must install tornado as root which will in turn mean that my virtualenv is practically useless.

Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75
Kunle Arewa
  • 1
  • 1
  • 3

1 Answers1

1

How exactly are you launching the app and interacting with the virtualenv? Sudo removes most environment variables, which will effectively deactivate any "activated" virtualenv. If you are using source $ENV/bin/activate, you need to this after sudo. Or you can avoid using activate by running the virtualenv's python executable: sudo $ENV/bin/python run.py.

Ben Darnell
  • 21,844
  • 3
  • 29
  • 50