PDA

View Full Version : python socket module problem



mwette
31st October 2006, 03:58 PM
I'm on FC6 using python 2.4.3. I'm frustrated by what I consider broken implementation.

Here is a simple python program "t1.py":


import socket
import sys

l = sys.stdin.readline()


If I run this code (./t1.py) in a terminal it brings up an X window.
If I comment out the "import socket" it does not bring up a window.

This seems like broken behavior to me. Is this a Fedora/RH issue
or does this exist in other implementations? How can a get rid of
the dependence on X?

mwette
31st October 2006, 04:03 PM
Aha. This is interesing.



$ DISPLAY= ./t1.py
Traceback (most recent call last):
File "./t1.py", line 3, in ?
import socket
File "/home/mwette/proj/python/socket.py", line 7, in ?
import gtk,sys
File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 76, in ?
_init()
File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 64, in _init
_gtk.init_check()
RuntimeError: could not open display
$