Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Unable to import arcrest in arcgis pro #243

Closed
CTLocalGovTeam opened this issue May 11, 2016 · 16 comments
Closed

Unable to import arcrest in arcgis pro #243

CTLocalGovTeam opened this issue May 11, 2016 · 16 comments

Comments

@CTLocalGovTeam
Copy link

@MikeMillerGIS

ArcRest v3.5.3

Bug

Repro Steps

  1. Install ArcGIS Pro for Python (ArcGIS Pro 1.2)
  2. Run setup.py install in ArcREST src directory using Pro's Python. This will install ArcREST to Python34.
  3. Use a gp tool with a script importing ArcREST
  4. Run tool in ArcGIS Pro
  5. Observe it fails to run with import error

image

@achapkowski
Copy link
Collaborator

@CTLocalGovTeam - Can you do the following from your Pro Python Windows:

import sys
print(sys.path)

Example output:

['c:\\program files\\arcgis\\pro\\Resources\\arcpy', 'c:\\program files\\arcgis\\pro\\bin\\Python\\DLLs', 'c:\\program files\\arcgis\\pro\\bin\\Python\\lib', 'C:\\Program Files\\ArcGIS\\Pro\\bin', 'c:\\program files\\arcgis\\pro\\bin\\Python', 'c:\\program files\\arcgis\\pro\\bin\\Python\\lib\\site-packages', 'c:\\program files\\arcgis\\pro\\Resources\\ArcToolbox\\Scripts', 'c:\\program files\\arcgis\\pro\\bin', 'C:\\Python34\\Lib\\site-packages']

Then see if ArcREST was installed in one of those paths?
Do you have more than one version of Python installed on your machine? If so, are you sure you are using the correct python.exe?

Thanks

@CTLocalGovTeam
Copy link
Author

@achapkowski

sys.path outputs this:

['', 'c:\\Python34\\python34.zip', 'c:\\Python34\\DLLs', 'c:\\Python34\\lib', 
'c:\\Python34', 'c:\\Python34\\lib\\site-packages', 'C:\\Program Files\\ArcGIS\\Pro\\bin', 
'C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy', 
'C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcToolBox\\Scripts']

ArcREST was installed to 'c:\Python34\lib\site-packages'
I can even import ArcREST on the commandline, but not in Pro

image

I do have python27 installed and it also has ArcREST installed and works fine in ArcGIS Desktop.

@CTLocalGovTeam
Copy link
Author

@achapkowski

Update:
When I imported ArcREST in commandline, it took a good 10 seconds to import.
Then I restarted Pro and importing ArcREST works now!
Maybe Pro needed a restart after installing ArcREST to site-packages

But now, I cannot import arcresthelper

image

@achapkowski
Copy link
Collaborator

@CTLocalGovTeam can you pull the latest version and run the setup.py again?

@CTLocalGovTeam
Copy link
Author

@achapkowski
Uninstalled ArcREST 3.5.3 using pip. It just deleted the egg info. Then manually deleted the arcrest and arcresthelper directories from site-packages.

Pulled ArcREST from master and when i try to run setup.py, it complains.

image

@MikeMillerGIS
Copy link
Member

What files/folders are in the SRC folder?

Sent from my Verizon Wireless 4G LTE DROID

@CTLocalGovTeam
Copy link
Author

@achapkowski

Finally, got it to work!
CDed into the src directory and ran setup.py from there.
Will post an update if i run into any issues further.
Thank you for helping.

@sharpering
Copy link
Contributor

@CTLocalGovTeam sorry that I have to open this thread again, but I have some difficulties using arcrest in ArcGIS Pro.

I have done the same steps as you have done... I have CDed into the src directory and ran setup.py from there, but when I want to use arcrest in ArcGIS Pro it always says that the module arcrest cannot be found.

I printed out the sys.path and copied the two folders "arcrest" and "arcresthelper" to "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages" manually. After doing so another error message appears:

image

I think the problem is the syntax. The scripts are written in 2.7 but Pro is using 3.x.

Any ideas?

@MikeMillerGIS
Copy link
Member

You need to use the most recent version in master. The version you have used a python 2.7 format for catching exceptions. This does not work in 3. These have been removed in master.

Here is line 43 in web/_base. - https://github.com/Esri/ArcREST/blob/master/src/arcrest/web/_base.py#L43

@sharpering
Copy link
Contributor

sharpering commented Jan 2, 2017

Thanks a lot :), that was the solution for this error. I am still wondering why I have to change one python script (_base.py) manually. I downloaded the last version (ArcRest 3.5.3) and I thought that such a problem would be adressed :).

After fixing this problem another error is showing up. It is the same as mentioned above by @CTLocalGovTeam:

image

As you can see in the following picture, there is a file "common.py":

image

Is it maybe possible that I work with an old version? If I try to run for example "Delete Data from Feature Servcie" I get the following error in ArcGIS Pro:

image

@MikeMillerGIS
Copy link
Member

MikeMillerGIS commented Jan 2, 2017 via email

@MikeMillerGIS
Copy link
Member

MikeMillerGIS commented Jan 2, 2017 via email

@MikeMillerGIS
Copy link
Member

I just tried with version in Master and the import works fine. I would remove the ArcRest and ArcRestHelper folders from your python folder and manually copy them back from master.

this works in python 3.x
import arcrest
from arcresthelper import securityhandlerhelper
config = {'username': 'UserName', 'password': 'Password'}
token = securityhandlerhelper.securityhandlerhelper(config)
print (token.securityhandler.token)

@sharpering
Copy link
Contributor

Thanks for the hint :). I removed all files from ArcRest and started a new installation. The import of arcrest and arcresthelper works fine now, but when I want to use the tool "Remove Data from Feature Service" I get some error messages. I have logged the messages / errors with Issue #317 and Issue #318.

I imported the Toolbox from the Master folder and I have tested this tool in ArcGIS Pro 1.3 and 1.4.

@MikeMillerGIS
Copy link
Member

MikeMillerGIS commented Jan 13, 2017 via email

@sharpering
Copy link
Contributor

Done :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants