Python path after installing ArcGIS Server

1049
9
Jump to solution
08-28-2017 04:38 AM
MarcWouters
New Contributor III

I have been running  scripts using Python 3.5 from ArcGIS Pro 1.4
(C:\Program Files (x86)\ArcGIS\Pro 1.4\bin\Python\envs\arcgispro-py3\python.exe) without any problem.

Last week I installed ArcGIS Server (ArcGIS Enterprise), and now my scripts all fail, starting with the import arcpy statement. Root cause error is builtins.NameError: name 'arcgisscripting' is not defined


File "c:\Program Files (x86)\ArcGIS\Pro 1.4\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 62, in __init__
  self._gp = arcgisscripting.create(11.0)

builtins.NameError: name 'arcgisscripting' is not defined

What have I done wrong ?

Any help is welcome !

Marc

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

I will have to dig a little deeper when I find some time.  As odd as this may sound, since you don't know much about Python, it might be quicker to uninstall Pro and Enterprise and re-install them in the opposite order to see if Pro is better about setting Python-related variables after Enterprise is installed.

View solution in original post

9 Replies
JoshuaBixby
MVP Esteemed Contributor

You didn't do anything wrong, you just installed an additional Python distribution that altered some of the system settings.  I can't recall right off the top all of the various settings that a new Python distribution can alter, but you will find plenty of information searching the internet.  Are the scripts that are failing being called from within ArcGIS Pro or are you running them outside of the application? 

0 Kudos
MarcWouters
New Contributor III

Hi Joshua,

The scripts are failing both in stand-alone mode, as being called from ArcGIS Pro (I just change the input part).

You propose searching on the Internet, but I have no clue what to look for : I have zero to none experience with Python distributions, I simply installed it right from the ArcGIS downloads.

What should I look for specifically ?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I will have to dig a little deeper when I find some time.  As odd as this may sound, since you don't know much about Python, it might be quicker to uninstall Pro and Enterprise and re-install them in the opposite order to see if Pro is better about setting Python-related variables after Enterprise is installed.

View solution in original post

MarcWouters
New Contributor III

I ended up re-installing ArcGIS Pro (version 2.0), and 'miraculously' everything worked again as normal.

Apparently you can avoid situations like this with Conda, but I am a newby in the Python world, and I'm satisfied with the current solution.

0 Kudos
MichaelVolz
Esteemed Contributor

Can you provide a snippet of how you call your script from outside of Pro?

0 Kudos
MarcWouters
New Contributor III

I can provide you a short snippet, but actually, it fails already at the 1st line !!!!

Therefor it doesn't matter whether I call it from ArcGIS Pro, or outside.

Because it's a "quick-and-dirty" script, lot's of stuff is hard coded, and changed for each run.

# start of my script -> fails at this 1st line already
import arcpy      
import os

import manageTables
import readProperties

# Option 1 : Get parameters from ArcGIS Pro toolbox
# inputProject = arcpy.GetParameterAsText(0)
# outputFolder = arcpy.GetParameterAsText(1)
# Option 2 : Get parameters hard coded
inputProject = r"Path/to/my/input/file"
outputFolder = r"Path/to/my/output/folder"

0 Kudos
MichaelVolz
Esteemed Contributor

My recommendation would be to call your python script from a Windows Scheduled Task where you can call the python exe explicitly from the correct Pro python install location, thereby bypassing the current automatic call to the AGS version of python.  I do this on a server where I have both Desktop (32-bit) python and AGS (64-bit) python installed.

0 Kudos
MarcWouters
New Contributor III

I don't understand why calling my script from a Scheduled Task (no experience at all with this), would make any difference.

In the external Python IDE (Wing), I can set the project properties to point directly to the correct Python version (c:\Program Files (x86)\ArcGIS\Pro 1.4\bin\Python\envs\arcgispro-py3\python.exe). This is not the problem.

It worked without any problem earlier.

There are some other settings or parameters - which I cannot find - which are causing this behaviour.

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

If you are running it externally, it probably is unaware that you have an ArcPro license.

Accessing licenses and extensions in Python—Geoprocessing and Python | ArcGIS Desktop 

Althought the help is for ArcPro, the CheckProduct (which checks for a license) does not appear to have an option for Pro, but that might be a place to start. CheckProduct—ArcPy Functions | ArcGIS Desktop 

0 Kudos