<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'  in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570147#M21990</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christopher&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you found a solution for this? I am having the same issue here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Aug 2019 06:17:48 GMT</pubDate>
    <dc:creator>simoxu</dc:creator>
    <dc:date>2019-08-21T06:17:48Z</dc:date>
    <item>
      <title>ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570146#M21989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a geoprocessing service on&amp;nbsp;my standalone ArcGIS Server v10.6.1 to perform advanced printing for web maps using arcpy.mp.&lt;SPAN class="" style="color: #0074b8; background-color: #ffffff; text-decoration: none;"&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/mapping/convertwebmaptoarcgisproject.htm" style="color: #0074b8; background-color: #ffffff; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;ConvertWebMapToArcGISProject&lt;/A&gt;&amp;nbsp;from ArcGIS Pro v2.3.1. Our application accesses secure services so I need to include the arcpy.ImportCredentials function.&amp;nbsp;When I run the script I get the following error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #0074b8; background-color: #ffffff; text-decoration: none;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="color: #505051; font-size: 12px;"&gt;&lt;TBODY&gt;&lt;TR style="background: url(&amp;quot;;"&gt;&lt;TD class="" style="background: #e5edf4; border-width: 1px; border-style: solid; border-color: #769dc0 #e5dac8 #769dc0 transparent; padding: 3px 5px;"&gt;Error executing tool. ConvertPdf : Traceback (most recent call last): File "D:\arcgisserver\directories\arcgissystem\arcgisinput\GP\ConvertPdf.GPServer\extracted\p20\arcgis_project\WebMapToArcGISProject.py", line 36, in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;importedConnections = arcpy.ImportCredentials(secure_server_connections) AttributeError: module 'arcpy' has no attribute 'ImportCredentials' Failed to execute (ConvertPdf). Failed to execute (ConvertPdf).&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I remove the ImportCredentials function, the script works and generates an image (if my web map json doesn't include a secure service).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are not using Portal and therefore this is not a federated server. So I am not able publish this service as a web tool. I had to write a script to create a service draft using arcpy.CreateGPSDDraft and used UploadServiceDefinition to publish to our server. The service appears to be using the propy python environment because it successfully uses the arcpy.mp module, but I don't know why it fails on ImportCredentials.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code published to the server:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #66d9ef;"&gt;import &lt;/SPAN&gt;arcpy
&lt;SPAN style="color: #66d9ef;"&gt;import &lt;/SPAN&gt;os
&lt;SPAN style="color: #66d9ef;"&gt;import &lt;/SPAN&gt;uuid

&lt;SPAN style="color: #75715e;"&gt;# The template location in the server data store
&lt;/SPAN&gt;scriptPath &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;sys.path[&lt;SPAN style="color: #ae81ff;"&gt;0&lt;/SPAN&gt;]
templatePath &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;os.path.&lt;SPAN style="color: #66d9ef;"&gt;join&lt;/SPAN&gt;(scriptPath, &lt;SPAN style="color: #e6db74;"&gt;'Templates'&lt;/SPAN&gt;)

&lt;SPAN style="color: #75715e;"&gt;# Input WebMap JSON
&lt;/SPAN&gt;Web_Map_as_JSON &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;GetParameterAsText&lt;/SPAN&gt;(&lt;SPAN style="color: #ae81ff;"&gt;0&lt;/SPAN&gt;)

&lt;SPAN style="color: #75715e;"&gt;# Input layout template
&lt;/SPAN&gt;Layout_Template &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;GetParameterAsText&lt;/SPAN&gt;(&lt;SPAN style="color: #ae81ff;"&gt;1&lt;/SPAN&gt;)

&lt;SPAN style="color: #75715e;"&gt;# Get the requested layout template pagx file
&lt;/SPAN&gt;templatePagx &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;os.path.&lt;SPAN style="color: #66d9ef;"&gt;join&lt;/SPAN&gt;(templatePath, Layout_Template &lt;SPAN style="color: #f92672;"&gt;+ &lt;/SPAN&gt;&lt;SPAN style="color: #e6db74;"&gt;'.pagx'&lt;/SPAN&gt;)

&lt;SPAN style="color: #75715e;"&gt;# Specify credentials for secured services in the WebMap JSON
&lt;/SPAN&gt;secure_server_connections &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;[
    os.path.&lt;SPAN style="color: #66d9ef;"&gt;join&lt;/SPAN&gt;(scriptPath, &lt;SPAN style="color: #e6db74;"&gt;'creds.ags'&lt;/SPAN&gt;),
]

&lt;SPAN style="color: #75715e;"&gt;# Import credentials
&lt;/SPAN&gt;importedConnections &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;ImportCredentials&lt;/SPAN&gt;(secure_server_connections)
   
&lt;SPAN style="color: #75715e;"&gt;# Convert the WebMap to an ArcGISProject
&lt;/SPAN&gt;result &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.mp.&lt;SPAN style="color: #66d9ef;"&gt;ConvertWebMapToArcGISProject&lt;/SPAN&gt;(Web_Map_as_JSON, templatePagx, &lt;SPAN style="color: #e6db74;"&gt;'LetterLandscape'&lt;/SPAN&gt;)
aprx &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;result.ArcGISProject
layout &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;aprx.&lt;SPAN style="color: #66d9ef;"&gt;listLayouts&lt;/SPAN&gt;()[&lt;SPAN style="color: #ae81ff;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #75715e;"&gt;# Set scale
&lt;/SPAN&gt;scale &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;GetParameterAsText&lt;/SPAN&gt;(&lt;SPAN style="color: #ae81ff;"&gt;3&lt;/SPAN&gt;)
layout &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;aprx.&lt;SPAN style="color: #66d9ef;"&gt;listLayouts&lt;/SPAN&gt;(&lt;SPAN style="color: #e6db74;"&gt;'LetterLandscape'&lt;/SPAN&gt;)[&lt;SPAN style="color: #ae81ff;"&gt;0&lt;/SPAN&gt;]
mapframe &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;layout.&lt;SPAN style="color: #66d9ef;"&gt;listElements&lt;/SPAN&gt;(&lt;SPAN style="color: #e6db74;"&gt;'MapFrame_Element'&lt;/SPAN&gt;)[&lt;SPAN style="color: #ae81ff;"&gt;0&lt;/SPAN&gt;]
mapframe.camera.scale &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;scale

&lt;SPAN style="color: #75715e;"&gt;# Set rotation
&lt;/SPAN&gt;rotate &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;GetParameterAsText&lt;/SPAN&gt;(&lt;SPAN style="color: #ae81ff;"&gt;4&lt;/SPAN&gt;)
mapframe.camera.heading &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;rotate
        
&lt;SPAN style="color: #75715e;"&gt;# Use the uuid module to generate a GUID as part of the output name
&lt;/SPAN&gt;&lt;SPAN style="color: #75715e;"&gt;# This will ensure a unique output name
&lt;/SPAN&gt;output &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #e6db74;"&gt;'WebMap_{}.png'&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;format&lt;/SPAN&gt;(&lt;SPAN style="color: #66d9ef;"&gt;str&lt;/SPAN&gt;(uuid.&lt;SPAN style="color: #66d9ef;"&gt;uuid1&lt;/SPAN&gt;()))
Output_File &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;os.path.&lt;SPAN style="color: #66d9ef;"&gt;join&lt;/SPAN&gt;(arcpy.env.scratchFolder, output)

&lt;SPAN style="color: #75715e;"&gt;# Export the WebMap
&lt;/SPAN&gt;dpi &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;GetParameterAsText&lt;/SPAN&gt;(&lt;SPAN style="color: #ae81ff;"&gt;5&lt;/SPAN&gt;)
layout.&lt;SPAN style="color: #66d9ef;"&gt;exportToPNG&lt;/SPAN&gt;(Output_File, &lt;SPAN style="color: #66d9ef;"&gt;int&lt;/SPAN&gt;(dpi))

&lt;SPAN style="color: #75715e;"&gt;# Set the output parameter to be the output file of the server job
&lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;SetParameterAsText&lt;/SPAN&gt;(&lt;SPAN style="color: #ae81ff;"&gt;2&lt;/SPAN&gt;, Output_File) 

&lt;SPAN style="color: #75715e;"&gt;# Clear credentials
&lt;/SPAN&gt;arcpy.&lt;SPAN style="color: #66d9ef;"&gt;ClearCredentials&lt;/SPAN&gt;(importedConnections)

&lt;SPAN style="color: #75715e;"&gt;# Clean up
&lt;/SPAN&gt;&lt;SPAN style="color: #66d9ef;"&gt;del &lt;/SPAN&gt;layout, aprx, result&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on how I can get this to work on our server?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:32:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570146#M21989</guid>
      <dc:creator>ChristopherCorliss1</dc:creator>
      <dc:date>2021-12-12T00:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570147#M21990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christopher&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you found a solution for this? I am having the same issue here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2019 06:17:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570147#M21990</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2019-08-21T06:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570148#M21991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ImportCredentials() was introduced in Pro 2.3 release. On the server side, you need 10.7 or higher.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2019 16:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570148#M21991</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2019-08-21T16:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570149#M21992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for giving the clarification. we are on 10.6.1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 04:44:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570149#M21992</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2019-08-22T04:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570150#M21993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/3685"&gt;Tanu Hoque&lt;/A&gt;‌. We are also on 10.6.1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2019 16:21:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/570150#M21993</guid>
      <dc:creator>ChristopherCorliss1</dc:creator>
      <dc:date>2019-09-06T16:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/1041834#M29846</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/449148"&gt;@TANH&lt;/a&gt;&amp;nbsp;is the only solution to this problem to upgrade an ArcGIS Server instance to 10.7 or higher? I have a arcpy.mp geoprocessing service that is trying to access premium layers in an aprx and, while this works locally before publishing, it will not work when running on our ArcGIS Server install at 10.6.1. Without the&amp;nbsp;&lt;SPAN&gt;ImportCredentials module available, I don't see any other options short of doing a full upgrade. Is that right? Could I just port the geoprocessing service over to arcpy.mapping and python 2.7 to use the equivalent there? Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 05:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/1041834#M29846</guid>
      <dc:creator>PatSmyth</dc:creator>
      <dc:date>2021-03-30T05:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Server - AttributeError: module 'arcpy' has no attribute 'ImportCredentials'</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/1042595#M29864</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/468798"&gt;@PatSmyth&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes, that is correct. you need to update your server to 10.7 or higher. And then use ArcGIS Pro 2.3 or higher to publish your service from.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 20:45:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/arcgis-server-attributeerror-module-arcpy-has-no/m-p/1042595#M29864</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2021-03-31T20:45:45Z</dc:date>
    </item>
  </channel>
</rss>

