Help with arcpy in PyCharm

3118
10
Jump to solution
11-30-2017 08:40 AM
MarkBinder
Occasional Contributor

I am attempting to do the Python for Everyone training using ArcGIS Pro and python 3.5. I've followed the instructions and installed PyCharm but I am unable to import arcpy so I am unable to run any scripts. 

Are there some settings that I need to change in order to use PyCharm?

Thanks

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MarkBinder
Occasional Contributor

I moved on to the next step and opened ArcGIS Pro and now PyCharm seems to be working. I was able to both run the script and import arcpy using the console. 

Thanks. 

View solution in original post

0 Kudos
10 Replies
JoshuaBixby
MVP Esteemed Contributor

What have you set for Project Interpreter - Help | PyCharm  ?

0 Kudos
MarkBinder
Occasional Contributor

I followed the instructions. So I set it as local and navigated to the Python.exe file in the indicated ArcGIS Pro/Python 3.5 subdirectory.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Which instructions?  The Esri instructions for using an IDE with Pro Python or the PyCharm ones?  Really, you need to be aware of both.

What exactly is the error message?  I use PyCharm regularly with ArcGIS Pro Python, and I haven't had problems importing ArcPy.

0 Kudos
MarkBinder
Occasional Contributor

I installed PyCharm and did this:

Browse to C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 and choose python.exe.
Click OK to set the project interpreter.
Click OK to close the Default Settings window.
Note: It may take a moment for the settings 

When I try to run the script I get an error when it tries to import arcpy.

0 Kudos
MarkBinder
Occasional Contributor

I moved on to the next step and opened ArcGIS Pro and now PyCharm seems to be working. I was able to both run the script and import arcpy using the console. 

Thanks. 

0 Kudos
DylanHarwell2
New Contributor

I've decided I don't really like developing in Spyder for Py3 stuff.. I went and got PyCharm, have done a bunch of internet sleuthing on how to use it with ArcGIS Pro's installation of Python 3 - sounds really simple, just configure the interpreter to your python.exe buried way down in the Pro folders.. Well I've done that and I can't import arcpy! It doesn't see it as a package. 

Anybody? Bueller... Bueller... 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

ArcPy won't show up in the package list, so that is expected, although I can't remember the exact reason why.

That bottom screenshot, is that your Python console in PyCharm?  If so, have you set the Python console to the "correct" Python interpreter because setting the console is different than your project.

If you have set the Python console interpreter to Pro Python, make sure Pro is set to automatically sign in and get a license (if using Named user); otherwise, you will end up getting a RuntimeError when trying to import the module.

0 Kudos
DylanHarwell2
New Contributor

Yes I set the project to use ArcPro Py3 as well as the interpreter. Still not importing arcpy, though I do see it in the 'intellisense' list when I type 'import ar...'

It might be the offline licensing issue you mentioned with Pro. It looks like my organization has disabled that, but I can use Spyder and work with ArcPy without being signed into Pro...

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

The screenshot you posted earlier looks like you are using the console, which has its own setting Python interpreter.  You mention that you set the project to use ArcGIS Pro Python, but you didn't state whether the console is using that interpreter as well.

0 Kudos