1

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).
3
  • What is the value of os.environ.get( "USERNAME" )? Could it be some special char in it?
    – BERA
    Jan 26, 2018 at 13:33
  • When I use the following piece of code it displays my user name as this: jnmiller
    – Jordan
    Jan 26, 2018 at 14:49
  • 1
    You cannot specify an owner when creating a version. Please edit the question to add some diagnostics to display the inputs.
    – Vince
    Jan 26, 2018 at 23:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.