The following script creates a new version in SDE but generates the following error below. Am I missing an environment?
# Name: SDE_CreateVersion
# Description: Creates a new SDE version
# Import system modules
import os
import arcpy
# Set local variables
sdeConnection = "Database Connections\Jordan.sde"
parentVersion = "sde.DEFAULT"
versionName = os.environ.get( "USERNAME" )
for version in arcpy.da.ListVersions(sdeConnection):
if version.name.split(".")[0] == versionName:
break
else:
# Execute CreateVersion
arcpy.CreateVersion_management(sdeConnection, parentVersion, versionName, "PUBLIC")
This is the error produced:
Traceback (most recent call last):
File "C:\Users\jnmiller\Desktop\Create Version.py", line 20, in <module>
arcpy.CreateVersion_management(sdeConnection, parentVersion, versionName, "PUBLIC")
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\management.py", line 18856, in CreateVersion
raise e
ExecuteError: ERROR 001148: Cannot create a version with the specified name.
Failed to execute (CreateVersion).
os.environ.get( "USERNAME" )
? Could it be some special char in it?