No module named gis

4683
15
07-25-2018 04:18 AM
RobertKnapik
New Contributor III

Hello,

I would like to run script in Python Command Prompt. I use arcgispro-py3. In Jupyter Notebook everything is ok. When I run script in Python Command Prompt I get message: "no module named gis". 

I will be grateful for your help,

Robert

Tags (2)
15 Replies
DanPatterson_Retired
MVP Emeritus

perhaps you script had something like this?

from arcgis.gis import GIS‍

where GIS is capitalized.

RobertKnapik
New Contributor III

I have "from arcgis.gis import GIS", but problem is the same. In jupyter notebook is ok.

0 Kudos
DanPatterson_Retired
MVP Emeritus

I know that works in Jupyter notebook... I just tried it and it works in Jupyter QTconsole as well

So you will have to show your script if you are running it from the python prompt rather than running stuff in one of the IDE's that can be used with ArcGIS PRO

RobertKnapik
New Contributor III

In the future I would like to run the script via Windows Server task scheduler, but I'm worried if it works if it does not work in Python Command Prompt.

0 Kudos
DanPatterson_Retired
MVP Emeritus

there might be a disconnect between the required python that is needed and the one associated with your command prompt.

run a sys.path to see what is returned to see if everything is associated with the anaconda distribution the Pro uses.

0 Kudos
RobertKnapik
New Contributor III

When I run sys.path I get something like this:

['',

'C:\\Program '
'Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\python36.zip',
'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\DLLs',
'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib',
'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3',
'C:\\Program '
'Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages',
'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\\envs\\arcgispro-py3\\lib\\site-packages\\future-0.16.0-py3.6.egg',
'C:\\Program '
'Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\pytz-2018.3-py3.6.egg',
'C:\\Program '
'Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\sympy-1.1.1-py3.6.egg']
>>>

0 Kudos
DanPatterson_Retired
MVP Emeritus

hmmm. look sort of normal, but I don't have it installed for all users, so I am not sure about some of the other entries.

That leave you with showing how you are trying to launch the script... and the script itself, the issue may lie in the contents of the py file.

0 Kudos
RobertKnapik
New Contributor III

In Python Command Prompt I try to open python script from a disk location for example: 

(arcgispro-py3) E:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>E:\Scripts\script.py
Traceback (most recent call last):
File "E:\Scripts\script.py", line 2, in <module>
from arcgis.gis import GIS
ImportError: No module named gis

My script:

0 Kudos
DanPatterson_Retired
MVP Emeritus

Here is an example of how to run a script from the command prompt

here is the script

# -*- coding: utf-8 -*-
from arcgis.gis import GIS
print("hello")