Select to view content in your preferred language

Visual Studio Code do not save files to disk (ArcGIS Pro conda based envs)

858
1
02-19-2023 07:45 AM
PetrSTASTNY
Occasional Contributor

Hi,

I want to write python scripts in Visual Studio Code and use arcpy module. ArcGIS Pro 3.x and Anaconda 3 are installed.
First, I had a problem with “conda” message – “The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program”. I solved the touble by this link:
https://stackoverflow.com/questions/56314710/the-term-conda-is-not-recognized-as-the-name-of-a-cmdle...

But now I'm solving another problem - when using conda-based python interpreters:
C:\Users\USER\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\python.exe
or C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
files are not written to disk at all. For example:

f = open(r"C:\_work\Output.txt","a")
f.close()

import arcpy
arcpy.FeatureClassToFeatureClass_conversion(r"C:\_work\File_A.shp", r"C:\_work", "File_B.shp")

After running this realy simple code, I don’t get any errors or warnings. But neither file Output.txt nor file File_B.shp cannot be found in C:\_work folder

When I run this line of code again:
arcpy.FeatureClassToFeatureClass_conversion(r"C:\_work\File_A.shp", r"C:\_work", "File_B.shp")

I'm getting his message:
arcpy.FeatureClassToFeatureClass_conversion(r"C:\_work\File_A.shp", r"C:\_work", "File_B.shp") arcgisscripting.ExecuteError: ERROR 000258: Output C:\_work\File_B.shp already exists Failed to execute (FeatureClassToFeatureClass). 

VSC_file_already_exists.PNG


But there is no file File_B.shp in my folder C:\_work


When I run this piece of code with a different python interpreter in Visual Studio Code (e.g.: C:\Users\USER\AppData\Local\Microsoft\WindowsApps\python3.9.exe)
f = open(r"C:\_work\Output.txt","a")
f.close()

the file Output.txt is created without any problems


Does anybody know where the problem could be?

 

Best regards, Petr

0 Kudos
1 Reply
Brian_Wilson
Honored Contributor

Since the command says the file exists my guess is the files are really there and that you need to refresh whatever tool you are using to see them.

What does this tell you? True or False?

import os

os.path.exists(r"C:\_work\Output.txt")

or

arcpy.Exists(r"C:\_work\File_B.shp")

Hope this helps

 

0 Kudos