I am 100% new to Python I am bumping into this weird issue regarding compatibility when switching between Windows and Linux. I implemented a small program that implements a TCP/IP socket that communicates with a device that supports server socket over TCP/IP. My program works fine when running on Windows so I decided to test it on Linux because ultimately I want to run it on CRONTAB as a scheduled task grabbing information from a server and export to an XML. This is the weird compilation error I received when trying to compile the same code on Linux (under python 2.6, 2.7 as well as 3.1)
python2.7 weatherScript.py Traceback (most recent call last): File "weatherScript.py", line 1, in <module> import socket File "/media/SWAP/weatherData/socket.py", line 117, in <module> except socket.error, msg: AttributeError: 'module' object has no attribute 'error' The corresponding code segments for that would be
import socket import sys import re from time import sleep from xml.dom.minidom import Document and
try: comSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error, msg: sys.stderr.write("[ERROR] %s\n" % msg[1]) sys.exit(1) #connecting to weather station try: comSocket.connect(()) except socket.error, msg: sys.stderr.write("[ERROR] %s\n" % msg[1]) sys.exit(2) Even when I remove the try-catch, the problem still persists. I am not sure whether there is any compilation incompatibility between Windows or Linux or not. Any help?
Other question would be: I want to run that python program under CRONTAB, is there any thing that I should change or include so that I can run it as a "script" or such?
Thank you so much!
weatherScript.pylocated, what is yoursys.path(or at least the part of it that corresponds toweatherData/socket.py)?