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

3145
7
Jump to solution
05-19-2019 08:44 PM
SamiSnunu
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)
0 Kudos
1 Solution

Accepted Solutions
SamiSnunu
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

0 Kudos
7 Replies
PaulLeBlanc1
Esri Contributor

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?

SamiSnunu
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

0 Kudos
SamiSnunu
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'

0 Kudos
PaulLeBlanc1
Esri Contributor

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

0 Kudos
VickyWang
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.  

~Vicky Wang~
SamiSnunu
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.

0 Kudos
VickyWang
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.

~Vicky Wang~