Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

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

$
0
0
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?

Code:

#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

Viewing all articles
Browse latest Browse all 2485

Trending Articles