<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Trouble accessing ArcPy in script outside of ArcGIS Pro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004925#M59130</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/106411"&gt;@SolanaFoo2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It could possibly be the python environment variable is referencing to a different version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the following in a bat file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"c:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" "D:\scriptfile.py"&lt;/P&gt;</description>
    <pubDate>Thu, 26 Nov 2020 02:47:06 GMT</pubDate>
    <dc:creator>ManishPatel</dc:creator>
    <dc:date>2020-11-26T02:47:06Z</dc:date>
    <item>
      <title>Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004918#M59128</link>
      <description>&lt;P&gt;I'm having no luck calling arcpy from a script that uses ArcGIS API for Python as well.&lt;/P&gt;&lt;P&gt;I've added every single path I can think of to the PYTHONPATH and path environment variables.&amp;nbsp; No luck.&amp;nbsp; Runs fine with ArcPy and imports&amp;nbsp;arcgis fine as well when run in a Script tool in Pro, or in a Notebook from Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doesn't run in a Notebook outside of Pro, or called in a bat file where the exe used is here: D:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the err (I've also seen no _base.py err):&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;E:\START\CalFire2020_New\PythonScripts\AGOL_Management&amp;gt;"D:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" E:\START\CalFire2020_New\PythonScripts\AGOL_Management\GroupExport.py&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp; File "E:\AGOL_Management\GroupExport.py",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;line 12, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp; File "D:\Program Files (x86)\ArcGIS\Desktop10.6\arcpy\arcpy\__init__.py", line&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;22, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from arcpy.geoprocessing import gp&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff0000"&gt;ImportError: cannot import name 'gp'&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 02:38:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004918#M59128</guid>
      <dc:creator>SolanaFoo2</dc:creator>
      <dc:date>2020-11-26T02:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004925#M59130</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/106411"&gt;@SolanaFoo2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It could possibly be the python environment variable is referencing to a different version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the following in a bat file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"c:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" "D:\scriptfile.py"&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 02:47:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004925#M59130</guid>
      <dc:creator>ManishPatel</dc:creator>
      <dc:date>2020-11-26T02:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004926#M59131</link>
      <description>&lt;P&gt;What do you get when you run these from sys?&amp;nbsp; This is my default path structure minus personal ones.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# ---- NOTE : replace C:\\arc_pro with your installation path
sys.executable
'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\python.exe'

sys.path
['C:\\arc_pro\\Resources\\ArcPy',
 ...snip...,
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\DLLs',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3',
 '',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages',
 'C:\\arc_pro\\bin',
 'C:\\arc_pro\\Resources\\ArcToolbox\\Scripts',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\future-0.18.2-py3.7.egg',
'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\pytz-2020.1-py3.7.egg',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\pywin32_ctypes-0.2.0-py3.7.egg',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\pywin32security',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\sympy-1.5.1-py3.7.egg',
 'C:\\arc_pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\IPython\\extensions',
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 02:50:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1004926#M59131</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-11-26T02:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005435#M59161</link>
      <description>&lt;P&gt;Hi Dan!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the cmd prompt:&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; sys.executable&lt;BR /&gt;'D:\\Python27\\ArcGISx6410.6\\python.exe'&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; sys.path&lt;BR /&gt;['', 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python', 'D:\\Python27\\ArcGISx6410.6&lt;BR /&gt;', 'D:\\Python27\\ArcGISx6410.6\\Scripts', 'D:\\Program Files (x86)\\ArcGIS\\Des&lt;BR /&gt;ktop10.6\\arcpy', 'D:\\Program Files (x86)\\ArcGIS\\Desktop10.6\\bin', 'D:\\Prog&lt;BR /&gt;ram Files\\ArcGIS\\Pro\\bin', 'D:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy\&lt;BR /&gt;\arcpy', 'D:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy', 'D:\\Program Files\&lt;BR /&gt;\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3', 'C:\\Program Files\\ArcGIS\\Pro&lt;BR /&gt;\\bin\\Python\\envs\\arcgispro-py3\\Lib', 'C:\\Windows\\SYSTEM32\\python27.zip',&lt;BR /&gt;'D:\\Python27\\ArcGISx6410.6\\DLLs', 'D:\\Python27\\ArcGISx6410.6\\lib', 'D:\\P&lt;BR /&gt;ython27\\ArcGISx6410.6\\lib\\plat-win', 'D:\\Python27\\ArcGISx6410.6\\lib\\lib-t&lt;BR /&gt;k', 'C:\\Users\\####\\AppData\\Roaming\\Python\\Python27\\site-packages', 'D:\\P&lt;BR /&gt;ython27\\ArcGISx6410.6\\lib\\site-packages', 'D:\\Program Files\\ArcGIS\\Server\&lt;BR /&gt;\bin', 'D:\\Program Files\\ArcGIS\\Server\\ArcPy', 'D:\\Program Files\\ArcGIS\\S&lt;BR /&gt;erver\\ArcToolBox\\Scripts']&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;However, trying to run as a batch file like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;"D:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" E:\START\CalFire2020_New\PythonScripts\AGOL_Management\GroupExport.py&lt;/P&gt;&lt;P&gt;Thanks for the response!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 07:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005435#M59161</guid>
      <dc:creator>SolanaFoo2</dc:creator>
      <dc:date>2020-11-30T07:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005436#M59162</link>
      <description>&lt;P&gt;Hi Manish,&lt;/P&gt;&lt;P&gt;What does propy.bat do?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 07:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005436#M59162</guid>
      <dc:creator>SolanaFoo2</dc:creator>
      <dc:date>2020-11-30T07:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005440#M59164</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/106411"&gt;@SolanaFoo2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;SPAN class="usertext"&gt;propy.bat&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;acts as a replacement for calling&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="usertext"&gt;python.exe&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="usertext"&gt;This link will provide you some background info:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/get-started/using-conda-with-arcgis-pro.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/arcpy/get-started/using-conda-with-arcgis-pro.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 07:49:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005440#M59164</guid>
      <dc:creator>ManishPatel</dc:creator>
      <dc:date>2020-11-30T07:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble accessing ArcPy in script outside of ArcGIS Pro</title>
      <link>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005460#M59166</link>
      <description>&lt;P&gt;You mention ArcGIS Pro, but the executable is for python 2.7 which is for arcmap. Which means that you don't have the correct environment activated.&lt;/P&gt;&lt;P&gt;For jupyterlab I use a desktop shortcut to set everything up&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Target 
C:\arc_pro\bin\Python\envs\arcgispro-py3\pythonw.exe "C:\arc_pro\bin\python\envs\arcgispro-py3\Scripts\jupyter-lab-script.py"
# Start in
C:\Arc_projects\JupyterNoteBooks
# ---- NOTE \arc_pro\ is the ArcGIS Pro installation folder
# ----- For jupyter notebook
# Target
C:\arc_pro\bin\Python\envs\arcgispro-py3\pythonw.exe "C:\arc_pro\bin\Python\envs\arcgispro-py3\Scripts\jupyter-notebook-script.py"&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Nov 2020 11:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trouble-accessing-arcpy-in-script-outside-of/m-p/1005460#M59166</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-11-30T11:43:26Z</dc:date>
    </item>
  </channel>
</rss>

