My python scripts were running fine and then I upgraded from ArcGIS for Desktop - ArcMap 10.3 to 10.4.1
Now when I open a Python window and type >>> print "test" nothing happens
when I type >>> import os
>>> print os.sys.path
nothing happens. I think ArcMap is looking for Python in the wrong location. How can I fix this?
I have this folder on my Windows 7 computer: C:\Python27\ArcGIS10.4
Solved! Go to Solution.
It is best to uninstall other versions to upgrading. but none the less, bring up your favourite IDE and see what your path object is.
What is show is for 10.5... similar to 10.4 no less.
Here is the python requirements link , you can select 10.4 to see if there was anything different.
But in the end, the python27\\ArcGISxx.x version should match, but make sure there are no stray links in the sys path.
>>> import sys
>>> sys.path
... snip ...
'C:\\Python27\\ArcGIS10.5\\DLLs',
'C:\\Python27\\ArcGIS10.5\\lib',
'C:\\Python27\\ArcGIS10.5\\lib\\plat-win',
'C:\\Python27\\ArcGIS10.5\\lib\\lib-tk',
'C:\\Python27\\ArcGIS10.5\\Lib\\SITE-P~1\\PYTHON~1',
'C:\\Python27\\ArcGIS10.5',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages\\win32',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages\\win32\\lib',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages\\Pythonwin'
...
>>> # This example uses Pythonwin for arcmap 10.5
It is best to uninstall other versions to upgrading. but none the less, bring up your favourite IDE and see what your path object is.
What is show is for 10.5... similar to 10.4 no less.
Here is the python requirements link , you can select 10.4 to see if there was anything different.
But in the end, the python27\\ArcGISxx.x version should match, but make sure there are no stray links in the sys path.
>>> import sys
>>> sys.path
... snip ...
'C:\\Python27\\ArcGIS10.5\\DLLs',
'C:\\Python27\\ArcGIS10.5\\lib',
'C:\\Python27\\ArcGIS10.5\\lib\\plat-win',
'C:\\Python27\\ArcGIS10.5\\lib\\lib-tk',
'C:\\Python27\\ArcGIS10.5\\Lib\\SITE-P~1\\PYTHON~1',
'C:\\Python27\\ArcGIS10.5',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages\\win32',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages\\win32\\lib',
'C:\\Python27\\ArcGIS10.5\\lib\\site-packages\\Pythonwin'
...
>>> # This example uses Pythonwin for arcmap 10.5
Thanks Dan, I typed the following commands into the Python window in ArcMap. I hit the Return Key after each line. I typed each line from you answer, then I re-started the computer but, when I type >>> print "test" and press return, I don't get any response from the Python window. I assume I am missing a step?
>>> import sys
>>> sys.path
>>> sys.path 'C:\\Python27\\ArcGIS10.4\\lib'
>>> sys.path 'C:\\Python27\\ArcGIS10.4\\lib\\plat-win'
so you don't use your own python IDE? ok, here is arcmap's
I tried >>> print("hey") and >>>print ("hey") and still nothing. I tried to look up the commands for import sys using the ArcMap Python window but I didn't find anything different from what you showed me. Should I use parens around the commands in the ArcMap Python window?
Rick, if you are having issues in the built-in Python window, you may want to uninstall Python using the
Windies program add/delete and run a repair on the install. Thus us mentioned in this thread Python Path Confusion Among other suggestions, including checking registry entries, but the python uninstall and repair-install (of ArcGIS) is the most benign.
if it is an external program (like Wing or pycripter) that you are opening up either separate for ArcGIS and/or by because you have the geoprocessing editor in ArcGIS set to use this external program, you may need to check the options/parameters of the external Python IDE and update that path.
re: using
print("test")
at the Python print, as Dan would probably mention, it's best to get in the habit of including the ( ) in the pring statement. It's not mandatory (but works) for ArcGIS which uses Python 2.x, but will be necessary in Pro and Python 3.x.
Thank you, I finally took your initial advice about uninstalling. I uninstalled and re-installed Python and then from the Windows Control Panel, Programs and Features, Uninstall or change a program, I selected ArcGIS 10.4.1 for Desktop and clicked Uninstall/Change which popped up a window which gave me the option to "Repair" the ArcGIS installation and now it is working perfectly.