How do you get Python 3.4 to see ArcGIS Pro arcpy?

12026
11
Jump to solution
10-30-2014 08:07 AM
curtvprice
MVP Esteemed Contributor

I am trying to access ArcGIS Pro's flavor of arcpy. I installed the 3.4.0 distributed with Pro (beta 5, and pr), open IDLE fine, but... arcpy is not automatically in the sys.path.

Is there a .pth file I am missing?

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> import arcpy

Traceback (most recent call last):

  File "<pyshell#0>", line 1, in <module>

    import arcpy

ImportError: No module named 'arcpy'

>>> import sys

>>> print("\n".join(sys.path))

C:\Windows\system32

C:\Python34\Lib\idlelib

C:\Python34\python34.zip

C:\Python34\DLLs

C:\Python34\lib

C:\Python34

C:\Python34\lib\site-packages

>>>

Tags (3)
1 Solution

Accepted Solutions
BruceHarold
Esri Regular Contributor

Hi

C:\Python34\Lib\site-packages\pro.pth

C:\Program Files\ArcGIS Pro\bin

C:\Program Files\ArcGIS Pro\Resources\ArcPy

C:\Program Files\ArcGIS Pro\Resources\ArcToolBox\Scripts

C:\Program Files\ArcGIS Pro\bin\Python\Lib\site-packages

C:\Python34\Lib\site-packages

View solution in original post

0 Kudos
11 Replies
BruceHarold
Esri Regular Contributor

Hi

C:\Python34\Lib\site-packages\pro.pth

C:\Program Files\ArcGIS Pro\bin

C:\Program Files\ArcGIS Pro\Resources\ArcPy

C:\Program Files\ArcGIS Pro\Resources\ArcToolBox\Scripts

C:\Program Files\ArcGIS Pro\bin\Python\Lib\site-packages

C:\Python34\Lib\site-packages

0 Kudos
BruceHarold
Esri Regular Contributor

Also, to set IDLE as your script editor in Options>Geoprocessing set your script editor:

C:\Python34\Lib\idlelib\idle.bat

0 Kudos
curtvprice
MVP Esteemed Contributor

Thanks so much Bruce, I'll try it as soon as I get a chance.

I do not have access to my Python34 folder (locked down installs) so I suppose I can do the same thing with the PYTHONPATH env variable.

Does 3.4 support an alternate user location for the .pth file?

curtvprice
MVP Esteemed Contributor

This list of paths worked great.

I have installed Pro single-user as I do not have admin access to this machine so cannot edit the Python34 folder - so I solve the problem using the PYTHONPATH environment variable. I launch python here from its own batfile so I don't confuse my Desktop environment, which has a PYTHONPATH set up to access my Desktop 10x scripts.

py34.bat

:: start python 3.4 with ArcGIS Pro arcpy available

@echo off

set AGPHOME=C:\Users\cprice\AppData\Local\Programs\ArcGIS Pro

set PYTHONPATH=^

%AGPHOME%\bin;^

%AGPHOME%\Resources\ArcPy;^

%AGPHOME%\Resources\ArcToolBox\Scripts;^

%AGPHOME%\bin\Python\Lib\site-packages;^

C:\Python34\Lib\site-packages

C:\Python34\python.exe %1 %2 %3 %4 %5

This seems to work fine:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> import arcpy

>>> arcpy.GetInstallInfo()

{'Version': '1.0', 'InstallTime': '8:45:39', 'SPBuild': 'N/A', 'ProductName': 'ArcGISPro', 'BuildNumber': '1472', 'InstallType': 'N/A', 'InstallDate': '10/30/2014', 'SourceDir': 'F:\\EsriMedia\\ArcGISPro_PreRelease\\ArcGISPro\\', 'SPNumber': 'N/A', 'Installer': 'cprice', 'InstallDir': 'c:\\users\\cprice\\appdata\\local\\programs\\arcgis pro\\'}

>>>

JanCibulka
New Contributor II

Hi,

I tried this, but after "import arcpy" windows throws "python.exe has stopped working" and whole script goes down. I admit, I am using Anaconda distribution, specifically Python 3.4 64bit. On Anaconda 2.7 with arcpy from 10.3 everything working fine.

Edit: Windows logging points on "\ArcGIS Pro\bin\AGOLHelper.dll"...

Edit 2: It's not Anaconda problem, it persists in Python 3.4, downloaded from Esri page, so it's apparently bug connected to latest ArcGIS Pro release.

Thanks.

0 Kudos
curtvprice
MVP Esteemed Contributor

I suggest taking a careful look at the sys.path to make sure there isn't a problem.

Also: have you turned on the checkbox from ArcGIS Pro to allow offline access to your Pro license?

JanCibulka
New Contributor II

It was the offline access to Pro license, after enabling it arcpy imports without problems.

Thanks very much.

curtvprice
MVP Esteemed Contributor

That's kind of weak.  Hey Esri GP gear heads - import arcpy should do this check and handle it!

Luke_Pinner
MVP Regular Contributor

C:\Python34\Lib\site-packages\pro.pth

C:\Program Files\ArcGIS Pro\bin

C:\Program Files\ArcGIS Pro\Resources\ArcPy

C:\Program Files\ArcGIS Pro\Resources\ArcToolBox\Scripts

C:\Program Files\ArcGIS Pro\bin\Python\Lib\site-packages

C:\Python34\Lib\site-packages

The above didn't work for me with 1.1 (first time playing with Pro today in a training course).

The following worked for me in a pth file:

C:\Program Files\ArcGIS\Pro\bin

C:\Program Files\ArcGIS\Pro\Resources\ArcPy

C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Scripts

C:\Program Files\ArcGIS\Pro\bin\Python\Lib\site-packages

C:\Python34\Lib\site-packages