christi_nelson

arcpy.env.workspace = sys.path[0] gives different results in PythonWin - BUG?

Discussion created by christi_nelson on Feb 15, 2013
Latest reply on Feb 17, 2013 by Caleb1987
Hi all,

When I run the following snippet in PythonWin, the results come back with the correct location (C:\PSL\Scripts).  However, when this code is loaded into the ArcMap Python Window, the results are different and incorrect!  I will be sharing a tool that will be run from the Python Window in ArcGIS and I need to create a (correct) relative workspace for it.  Suggestions?

#import modules and define workspace
import arcpy
import os
import traceback
import sys

arcpy.env.workspace = sys.path[0]

print arcpy.env.workspace


When run in PythonWin, I get:

>>> C:\PSL\Scripts

When run in ArcMap Python Window, I get:

C:\WINDOWS\system32\python26.zip

I need ArcMap Python Window to return the same value as the value from PythonWin!!!

Im using ArcGIS 10 (ArcInfo level), Python26, Windows 7

Outcomes