Hi,In my organization we have Python scripts used for data checks, which use ArcPy (ArcGIS 10.0 SP4) and also the smtplib modul,e so we can receive automated emails regarding data errors. Problem we are finding is if try these scripts on our laptops. Not only cannot get script to connect to email server (which is not a problem I expect help for here), but it also semi-permanently breaking ArcPy AFTER failing to connect to email server via smtp module. I cannot understand why the two are linked? Simplest case from command prompt:
C:\>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import smtplib
>>> server=smtplib.SMTP('<MAIL SERVER>')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python26\lib\smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python26\lib\socket.py", line 514, in create_connection
raise error, msg
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
>>> import arcpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, i
n <module>
from geoprocessing import gp
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.p
y", line 14, in <module>
from _base import *
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py",
line 568, in <module>
env = GPEnvironments(gp)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py",
line 565, in GPEnvironments
return GPEnvironment(geoprocessor)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py",
line 521, in __init__
self._refresh()
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py",
line 523, in _refresh
envset = (set(env for env in self._gp.listEnvironments()))
RuntimeError: NotInitialized
Now, ArcPy is broken on this laptop, running any ArcPy script with or without smtplib module. If I tried a script from a Toolbox, or any script with import ArcPy it will fail with the above error. I can import arcgisscripting successfully, however.Rebooting makes no difference, uninstalling Python and ArcGIS 10.0 makes no difference. However, over time (maybe a week or two) ArcPy returns. I just wondered if anyone had experienced this? There is a definite link with smtplib causing the problem to the ArcPy module and have reproduced it on multiple laptops here, never desktop PCs where the same is fine. Thanks.