Error: module 'arcpy' has no attribute 'pt' when creating the utility network in stand-alone python script

665
7
Jump to solution
05-19-2019 08:44 PM
Highlighted
New Contributor III

In the documentation:

http://solutions.arcgis.com/utilities/help/utility-network-automation/tool-reference/stage-utility-n...

.# Create the new utility network

arcpy.pt.StageUtilityNetwork(sde, service_territory, dataset, network_name)

I'm running  stand-alone script, and got the error message"

in <module>
arcpy.pt.StageUtilityNetwork(
AttributeError: module 'arcpy' has no attribute 'pt'

Not sure why this is happening..

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor III

Many thanks @Vicky for the hint!

So this simply and only worked for me:  arcpy.StageUtilityNetwork_pt()

Yes, I made sure I already have the cloned python environment.

View solution in original post

Reply
0 Kudos
7 Replies
Highlighted
Occasional Contributor III

What version of untools do you have installed? You can check by running the following from Python window:

import untools

print(untools.__version__)

Do you see the Utility Network Package Tools toolbox?

Highlighted
New Contributor III

It's 2.3.2, I ran your command in Pro python editor.

However, if I run it in a stand-alone, it gives exception, and at the end of the long error traceback:

raise ImportError('dateutil 2.5.0 is the minimum required version')
ImportError: dateutil 2.5.0 is the minimum required version

Reply
0 Kudos
Highlighted
New Contributor III

I also upgraded both to the ArcPro 2.3.3, and untools 2.3.3, still got the same error message:

arcpy.pt.StageUtilityNetwork(
AttributeError: module 'arcpy' has no attribute 'pt'

Reply
0 Kudos
Highlighted
Occasional Contributor III

Did this machine have a previous version of Pro (eg 2.2) installed? Can you post a screenshot of the python backstage?

Reply
0 Kudos
Highlighted
Esri Contributor

Not sure if you got the solution yet.

It might worth to check with your python path where you installed the untools.

untools is normally required a clone python environment and it's a different python path from default ArcGIS Pro python location. 

The different python path can be viewed from ArcGIS Pro /Python/management environment.

It will look similar to "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone"

you can execute the arcpy.pt.StageUtilityNetwork() or arcpy.StageUtilityNetwork_pt() from there afer import arcpy library.  

Highlighted
New Contributor III

Many thanks @Vicky for the hint!

So this simply and only worked for me:  arcpy.StageUtilityNetwork_pt()

Yes, I made sure I already have the cloned python environment.

View solution in original post

Reply
0 Kudos
Highlighted
Esri Contributor

Hi Sami, 

Good to know that at least one of the method is working for you.

UtilityNetworkPackageTools arcpy.pt is a module of the ArcPy site package. Both arcpy.pt.StageUtilityNetwork() and arcpy.StageUtilityNetwork_pt() are the same function but use different name/way to call the function of UtilityNetworkPackageTools.

 

Somehow, you are not able to load the pt module but call arcpy.StageUtilityNetwork_pt() directly. It might something wrong in the python clone environment with an installed site package.   

May try to clone another python environment and install untools again through ArcGIS Pro> Python Package Manager. Then test the pt model again in the new clone environment.

I used the ArcGIS Pro 2.3.3 with untools 2.3.3.