Hi, I'm trying to use Pycharm, as IDE for python, but it seemd that the function arcpy.env is missing from __init_.PY...
I'm using C:\Python27\ArcGISx6410.5 interpreter.
When I try to run it inside PyCharm I get :
C:\Python27\ArcGISx6410.5\python.exe U:/Prog/PYScript/Geosoft2ArcGIS.py
Traceback (most recent call last):
File "U:/Prog/PYScript/Geosoft2ArcGIS.py", line 12, in <module>
import arcpy
File "c:\arcgis\desktop10.7\ArcPy\arcpy\__init__.py", line 22, in <module>
from arcpy.geoprocessing import gp
ImportError: cannot import name gp
it is there,
from arcpy.geoprocessing import gp
dir(gp)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass_.... snip ...
can you do a basic... import arcpy ..., if not then your environment isn't installed properly or you are using the wrong python and not the one distributed with Arc*
ArcGIS installed it there :
Yves Allaire Technicien sénior en géologie
yves.allaire@agnicoeagle.com Direct 819.874.5980 ,4103603
Agnico Eagle Mines Limited - Exploration Val-d’Or - 765, chemin de la mine Goldex - Val-d'Or, QC, Canada J9P 7G4
agnicoeagle.com<http://agnicoeagle.com> <https://facebook.com/agnicoeagle> <http://www.twitter.com/agnicoeagle> <http://www.linkedin.com/company/312686> <http://www.youtube.com/agnicoeaglevideos>
De : Dan Patterson <geonet@esri.com>
Envoyé : 5 février 2020 14:28
À : Yves Allaire <yves.allaire@agnicoeagle.com>
Objet : Re: - Re: env() reference
CAUTION: EXTERNAL
nothing showing in your response, so did the simple
import arcpy
work or did it fail too?
I've repaired ArcGIS
In Pycharm the interpreter is : I've attached a screen capture.
C:\Python27\ArcGISx6410.5\python.exe
After running this is what shows :
PyDev console: starting.
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) on win32
runfile('U:/Prog/PYScript/Geosoft2ArcGIS.py', wdir='U:/Prog/PYScript')
Traceback (most recent call last):
File "
import Arcpy
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named Arcpy
Yves Allaire Technicien sénior en géologie
yves.allaire@agnicoeagle.com Direct 819.874.5980 ,4103603
Agnico Eagle Mines Limited - Exploration Val-d’Or - 765, chemin de la mine Goldex - Val-d'Or, QC, Canada J9P 7G4
agnicoeagle.com<http://agnicoeagle.com> <https://facebook.com/agnicoeagle> <http://www.twitter.com/agnicoeagle> <http://www.linkedin.com/company/312686> <http://www.youtube.com/agnicoeaglevideos>
De : Dan Patterson <geonet@esri.com>
Envoyé : 5 février 2020 16:44
À : Yves Allaire <yves.allaire@agnicoeagle.com>
Objet : Re: - Re: env() reference
CAUTION: EXTERNAL
Let's try again
import Arcpy
is wrong... use lowercase for 'arcpy'.
Also, whats up with the 7 jpg files every time you post.
You can embed images in a thread using the camera icon on the button bar above.
Hi Dan, sorry about the capital A in Arcpy, I'm used to vba, no need to worry about leter cases !
I've corrected it and it't back to my gp problem
When I run this code :
import arcpy
I get :
raceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "U:/Prog/PYScript/Geosoft2ArcGIS.py", line 12, in <module>
import arcpy
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "c:\arcgis\desktop10.7\ArcPy\arcpy\__init__.py", line 22, in <module>
from arcpy.geoprocessing import gp
ImportError: cannot import name gp
You have to point pycharm to use the pythonw.exe (or python.exe) that is in the same path as arcpy. "c:\arcgis\desktop10.7\ArcPy\....
somewhere in that path, however, remembering back to the arcmap days, I thought python was installed in a c:\python\arcmapxxx\ path???
ArcGIS Pro cleans this all up.
In any event, you have to locate the 'arcpy' folder, backtrack to find the python.exe file in that path and set pycharm to use it and not another python, which I suspect you have installed somewhere.
If you need 64 bit, you should also switch to Pro if possible, since there are a number of issues with the background geoprocessing and separate python install that is required.
Good luck
Dan you are correct. ArcMap's default install path ( At least on my machine ) is:
C:\Python27\ArcGIS10.5\python.exe
For Pro, the path to python for my machine is:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
Yves, have you tried a full uninstall and reinstall of arcmap?
Hi Dan,
I've removed the Python option (modify the ArcMap installation), then add it again.
It's now saved in C:\Python27\ArcGIS10.7, I've tried both the Python and Pythonw
sys.path.extend(['U:\\Prog\\PYScript', 'C:/Python27/ArcGIS10.7'])