<?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: Path to the current notebook .ipynb that works both in ArcGIS Pro 3 and Jupyter in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243150#M63699</link>
    <description>&lt;P&gt;Interestingly, that returns &lt;FONT face="courier new,courier"&gt;C:\Users\&lt;EM&gt;myusername&lt;/EM&gt;\&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;AppData\Local\Temp\ipykernel_8588\4269868497.py&lt;/FONT&gt; which I suspect may be something created by the notebook environment for the code cell -- not sure how notebook cells get handled by the python interpreter.&amp;nbsp; Not the solution yet -- don't see how I'd get tot the &lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt; path from there -- but thanks for the suggestion.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2022 23:46:24 GMT</pubDate>
    <dc:creator>JerryDavis</dc:creator>
    <dc:date>2022-12-21T23:46:24Z</dc:date>
    <item>
      <title>Where is what I'm editing?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243082#M63682</link>
      <description>&lt;P&gt;I'm trying to find a way to access the path of the notebook file (&lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt;) that I'm currently editing, in a way that would work either in ArcGIS Pro or in an external IDE like Jupyter or VS-code.&amp;nbsp; What I've done in the past, with ArcGIS Pro 2.8 (and possibly 2.9), is to use &lt;FONT face="courier new,courier"&gt;os.getcwd()&lt;/FONT&gt;to provide &lt;EM&gt;the folder&lt;/EM&gt; that the current file being edited is in.&amp;nbsp; This works in an external IDE but doesn't work in ArcGIS Pro anymore.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Pro, something like the following will work, at least with the default workspace location, to provide the project folder:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;os.path.dirname(arcpy.env.workspace)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;... and that &lt;FONT face="courier new,courier"&gt;os.path.dirname()&lt;/FONT&gt; method will of course also work if we know the path for the notebook file itself. However the same method will not work when editing the file with an external IDE like VS-code or Jupyter, since there's no knowledge of the default workspace for the project, and indeed there's no knowledge of the ArcGIS Pro project at all: our file is just sitting in a folder.&lt;/P&gt;&lt;P&gt;I purposefully standardize on editing these notebook files in the project folder (a slightly modified logic would work if I used a 'source' or 'notebooks' folder within the project folder just to keep things organized), to keep things simple for students; they can do things differently if they need to down the road as they get more comfortable. But currently, in ArcGIS Pro 3, &lt;FONT face="courier new,courier"&gt;os.getcwd()&amp;nbsp;&lt;/FONT&gt;just returns&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'C:\\WINDOWS\\system32'&lt;/PRE&gt;&lt;P&gt;which is clearly&amp;nbsp;&lt;EM&gt;not&amp;nbsp;&lt;/EM&gt;the project folder, and not where the &lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt; file I'm editing is located.&amp;nbsp; There are what would seem to be obvious advantages in being able to edit a notebook either in ArcGIS Pro or an external IDE, and go back and forth, but I haven't figured out how to do this in ArcGIS Pro 3.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's a typical situation I want to work in both places, to set the workspace to a geodatabase &lt;FONT face="courier new,courier"&gt;"pen.gdb"&lt;/FONT&gt; in my project folder, thus providing code that is portable within the project folder, and an easy way to create other resources (e.g. geodatabases, folders) within that project folder.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; arcpy, os&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;projdir = os.getcwd()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;arcpy.env.workspace = projdir + &lt;/SPAN&gt;&lt;SPAN&gt;"\\pen.gdb"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It all boils down to a simple question:&amp;nbsp; &lt;EM&gt;Where is what I'm editing?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Environment:&amp;nbsp;&amp;nbsp;[ArcGIS Pro 3.0.3, installed on my computer for all users, not just my user profile; Windows 10]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 00:42:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243082#M63682</guid>
      <dc:creator>JerryDavis</dc:creator>
      <dc:date>2022-12-23T00:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Path to the current notebook .ipynb that works both in ArcGIS Pro 3 and Jupyter</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243109#M63687</link>
      <description>&lt;P&gt;I am not sure if I am answering the question you are asking but if you want to use an external IDE with your ArcGIS pro cloned environment that environment python interpreter can be found at&amp;nbsp;C:\Users\%USER%\AppData\Local\ESRI\conda\envs\arcgispro-py3-%clone name%&lt;/P&gt;&lt;P&gt;If you want to find the location where arcgis pro stores the internal jupyter notebooks created in arcgis pro I think by default those notebooks are found in the same directory as the pro project, which by default might be&amp;nbsp;C:\users\%user%\documents\arcgis\projects&lt;/P&gt;&lt;P&gt;I think you would probably need to somewhat coordinate the location of the jupyter notebook with the interpreter environment to get the results you would expect working with an IDE outside pro, especially if you want to use the arcgis libs in that ide.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 21:41:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243109#M63687</guid>
      <dc:creator>KyleGonterwitz</dc:creator>
      <dc:date>2022-12-21T21:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Path to the current notebook .ipynb that works both in ArcGIS Pro 3 and Jupyter</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243120#M63692</link>
      <description>&lt;P&gt;Thanks for the suggestion, but I don't think that fixes it.&amp;nbsp; I'm already standardizing on &lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt; files being stored in the project folder; I'm just needing my code to be able to use the path to that project folder, which should be the same as the folder my current &lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt; is stored in, as you note.&amp;nbsp; That I can usually get within ArcGIS Pro by using&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;os.path.dirname(env.workspace)&lt;/FONT&gt;, but that doesn't work from an external IDE like Jupyter or VS-code, so I had found that &lt;FONT face="courier new,courier"&gt;os.getcwd()&lt;/FONT&gt; would work in either case.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That works in Jupyter/VS-code and displays the folder the current file is in (which in my practice is the ArcGIS Pro project folder), but in ArcGIS Pro when editing the same file returns &lt;FONT face="courier new,courier"&gt;C:\\Windows\\system32&lt;/FONT&gt;, not where the &lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt; I'm currently editing resides.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm trying to find code that will work in either environment when editing the same file.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 22:04:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243120#M63692</guid>
      <dc:creator>JerryDavis</dc:creator>
      <dc:date>2022-12-21T22:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Path to the current notebook .ipynb that works both in ArcGIS Pro 3 and Jupyter</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243135#M63696</link>
      <description>&lt;P&gt;This works if you are running code in separate IDE and reports the filename of the script running.&amp;nbsp; But, does not seem to work in a notebook, maybe it helps figure it out???&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import inspect

configfile = (inspect.getfile(lambda:None))

print(configfile)&lt;/LI-CODE&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 23:03:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243135#M63696</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-12-21T23:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Path to the current notebook .ipynb that works both in ArcGIS Pro 3 and Jupyter</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243150#M63699</link>
      <description>&lt;P&gt;Interestingly, that returns &lt;FONT face="courier new,courier"&gt;C:\Users\&lt;EM&gt;myusername&lt;/EM&gt;\&lt;/FONT&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;AppData\Local\Temp\ipykernel_8588\4269868497.py&lt;/FONT&gt; which I suspect may be something created by the notebook environment for the code cell -- not sure how notebook cells get handled by the python interpreter.&amp;nbsp; Not the solution yet -- don't see how I'd get tot the &lt;FONT face="courier new,courier"&gt;.ipynb&lt;/FONT&gt; path from there -- but thanks for the suggestion.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 23:46:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243150#M63699</guid>
      <dc:creator>JerryDavis</dc:creator>
      <dc:date>2022-12-21T23:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Where is what I'm editing?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243927#M63789</link>
      <description>&lt;P&gt;"Well, I have no idea how this happened, but somehow os.getcwd() is now returning the project folder in ArcGIS Pro 3, as before.&amp;nbsp; It's a Christmas miracle...."&lt;/P&gt;&lt;P&gt;I posted the above and accepted that as a solution.&amp;nbsp; However, the problem cropped up again.&amp;nbsp; What appears to be happening is that &lt;FONT face="courier new,courier"&gt;os.getcwd()&lt;/FONT&gt;&amp;nbsp;not surprisingly simply gets the current working directory (thus the name &lt;FONT face="courier new,courier"&gt;cwd&lt;/FONT&gt;) in memory at the time.&amp;nbsp; If you start a new project, it'll have that project folder in memory, and that also seems to stick pretty well, except when it doesn't. Here's what it looks like when it works, for a project &lt;FONT face="courier new,courier"&gt;MyProject21&lt;/FONT&gt; I created in the &lt;FONT face="courier new,courier"&gt;ArcGIS\\Projects&lt;/FONT&gt; folder:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JerryDavis_0-1672254995916.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59387iC775B1C84077838A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JerryDavis_0-1672254995916.png" alt="JerryDavis_0-1672254995916.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, I still sometimes get &lt;FONT face="courier new,courier"&gt;C:\\WINDOWS\\system32&lt;/FONT&gt;&amp;nbsp;as shown below (or another wrong folder, maybe from another project) and I haven't yet figured out quite when that happens, or how to fix it when it doesn't, in a repeatable way, so I can provide clear instructions to students.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JerryDavis_1-1672255019603.png" style="width: 218px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59388iACE4846636C4894A/image-dimensions/218x60?v=v2" width="218" height="60" role="button" title="JerryDavis_1-1672255019603.png" alt="JerryDavis_1-1672255019603.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 21:54:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1243927#M63789</guid>
      <dc:creator>JerryDavis</dc:creator>
      <dc:date>2022-12-28T21:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Where is what I'm editing?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1245910#M64035</link>
      <description>&lt;P&gt;This is happening to me as well. Just know you aren't alone. Going to try and open a ticket with ESRI.&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 00:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1245910#M64035</guid>
      <dc:creator>NickPappinWSU</dc:creator>
      <dc:date>2023-01-06T00:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Where is what I'm editing?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1246585#M64098</link>
      <description>&lt;P&gt;Hey Jerry,&lt;/P&gt;&lt;P&gt;I opened a ticket and while working with them found that if I open ArcGIS by double clicking on the project file vs opening up ArcGIS from the start menu and then opening the project it seems to open dependably in the project folder. I will try and post again with any new info.&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 19:29:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1246585#M64098</guid>
      <dc:creator>NickPappinWSU</dc:creator>
      <dc:date>2023-01-09T19:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Where is what I'm editing?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1264033#M66188</link>
      <description>&lt;P&gt;Thanks for checking on that, Nick, and thanks to Esri's support responder.&amp;nbsp; That solution makes sense, too, since by navigating to the folder in the os, you've set the current folder from its perspective.&amp;nbsp; I've tended to be inconsistent in how I open ArcGIS Pro.&lt;/P&gt;&lt;P&gt;Jerry&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 16:24:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/where-is-what-i-m-editing/m-p/1264033#M66188</guid>
      <dc:creator>JerryDavis</dc:creator>
      <dc:date>2023-03-03T16:24:46Z</dc:date>
    </item>
  </channel>
</rss>

