<?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: ArcGIS Pro bug?: Can't import custom Python module in &amp;quot;Calculate Value&amp;quot; tool of ModelBuilder in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196541#M8696</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3355" target="_blank"&gt;Curtis Price&lt;/A&gt;‌ Thanks for digging into this. I'm doing some research on my end, and will post here when that's done. For now, I recommend doing:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; sys
sys&lt;SPAN class=""&gt;.&lt;/SPAN&gt;path&lt;SPAN class=""&gt;.&lt;/SPAN&gt;insert&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;''&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the code block, as you mentioned in your second example. This is the exact behavior of a typical Python process, and will prepend the working directory of the current Pro project to the search path for Python code. There are valid reasons to block this behavior in an embedded use, but I'm checking if they apply to Pro specifically.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;/P&gt;&lt;P&gt;Shaun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:49:28 GMT</pubDate>
    <dc:creator>ShaunWalbridge</dc:creator>
    <dc:date>2021-12-11T09:49:28Z</dc:date>
    <item>
      <title>ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196534#M8689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; This post is NOT about pure Python toolboxes, but ordinary ModelBuilder toolboxes enhanced with Python scripts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can ESRI confirm this? I am running into an issue where it seems Pro won't import custom Python modules / scripts in a &lt;STRONG&gt;Calculate Value&lt;/STRONG&gt; tool of ModelBuilder. I can successfully import default ArcGIS Python modules like &lt;STRONG&gt;io&lt;/STRONG&gt; etc, just not my own modules written as scripts. Pro bails out with a "ModuleNotFoundError".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid confusion, with "import", I mean using a Python module &lt;STRONG&gt;import&lt;/STRONG&gt; statement in the Python code textbox of the Calculate Value tools, so like:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import os&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import MyModule&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doesn't happen in ArcMap at all. Even if the module is not imported in the toolbox, ArcMap will find it if it is located in the same folder as the toolbox. Pro fails both with a script in the same folder as the toolbox, as well as with imported scripts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the attached screenshot from Pro 2.1.2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2018 21:23:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196534#M8689</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-29T21:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196535#M8690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Marco... perhaps models are set up differently.&amp;nbsp; I import my own modules (aka scripts) into my scripts in conventional toolboxes all the time, where they are found if they are located in the same location as the toolbox's script.&lt;/P&gt;&lt;P&gt;Export your model to a script to see if the paths are hardcoded or not&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2018 22:00:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196535#M8690</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-03-29T22:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196536#M8691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is &lt;STRONG&gt;not&lt;/STRONG&gt; about importing scripts / modules into another script / module part of a conventional ModelBuilder toolbox. Like you say, that works both in ArcMap and Pro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is &lt;EM&gt;specifically&lt;/EM&gt; with custom scripts / modules imported with the Python import statement inside the code block of a &lt;STRONG&gt;Calculate Value&lt;/STRONG&gt; "ModelBuilder-only-tool". That works in ArcMap, but fails in Pro if the imported module is a custom script I wrote myself, so not part of the default ArcGIS Python install.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2018 22:18:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196536#M8691</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-29T22:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196537#M8692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok... so it doesn't work the same way.&amp;nbsp; there is too much % this % that stuff in the help topic to figure out and there is no mention of imports.... sorry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2018 22:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196537#M8692</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-03-29T22:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196538#M8693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/curtvprice"&gt;curtvprice&lt;/A&gt;‌ you use modelbuilder.&amp;nbsp; in Pro?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2018 00:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196538#M8693</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-03-30T00:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196539#M8694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I made a little test model tool to look at this. I created it in ArcMap and created it in Pro. Comparing the results, I found something very interesting, that you can see from the Python prompts.&amp;nbsp;&amp;nbsp;Pro's sys.path does&amp;nbsp;not have "" as the first element as we normally see in most Python implementations!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note,&amp;nbsp;my experience is that &lt;STRONG&gt;os.curdir (which is what the blank entry means in the sys.path) is not the folder with the tbx,&lt;/STRONG&gt;&amp;nbsp;but the current ArcMap home folder (where the mxd is saved) or the Pro project folder.&amp;nbsp; Would like to know a good way to do your use case (find the current folder where the model's tbx lives) no matter where the tbx is relative to the map document or project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArcMap 10.5's Python window:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;''&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From Pro's Python window:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'c:\\program files\\arcgis\\pro\\Resources\\arcpy'&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can get your script to work by adding the current folder to the sys.path. Maybe.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Calculate value expression:&amp;nbsp; f()&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Code block:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insert&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;### your module ###&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;f&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# do stuff&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is this is a feature not a bug. &lt;A href="https://community.esri.com/migrated-users/31672" target="_blank"&gt;Shaun Walbridge&lt;/A&gt;‌ do you have any enlightenment for us?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:49:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196539#M8694</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T09:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196540#M8695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Can ESRI confirm this?&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Just a note: if you want to report a bug, you need to open a support incident with support.esri.com -- this is a community site which is useful, but not the place to report bugs.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2018 05:06:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196540#M8695</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2018-03-30T05:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196541#M8696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3355" target="_blank"&gt;Curtis Price&lt;/A&gt;‌ Thanks for digging into this. I'm doing some research on my end, and will post here when that's done. For now, I recommend doing:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt; sys
sys&lt;SPAN class=""&gt;.&lt;/SPAN&gt;path&lt;SPAN class=""&gt;.&lt;/SPAN&gt;insert&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;''&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the code block, as you mentioned in your second example. This is the exact behavior of a typical Python process, and will prepend the working directory of the current Pro project to the search path for Python code. There are valid reasons to block this behavior in an embedded use, but I'm checking if they apply to Pro specifically.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;/P&gt;&lt;P&gt;Shaun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:49:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196541#M8696</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2021-12-11T09:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196542#M8697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Curtis for all the detective work. Yes, I know about the support stuff, but as I wasn't exactly sure if this was a "bug" or, as you stated, a possible "feature", so I considered posting here more appropriate for now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, since this seemed to be a kind of trivial issue related to path interpretation, I hoped someone in the community like you, would have ideas for a solution (as you did).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, despite implementing your solution in the top part of the code block of the &lt;STRONG&gt;Calculate Value&lt;/STRONG&gt; tool, it still fails to locate the module in Pro, and errors out with the &lt;STRONG&gt;ModuleNotFoundError&lt;/STRONG&gt;, as I showed in the screenshot of the first post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I also wrote there, the same model runs fine in ArcMap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2018 22:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196542#M8697</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-30T22:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196543#M8698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm thinking that in Pro the the home folder may not where you think it is. In your model, try setting up a Calculate Value tool that shows this path will help you check, below.&lt;/P&gt;&lt;P&gt;For your import to work the returned path will have to be the folder where the module you are trying to import lives.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Calculate Value expression: test()&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Code block:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;test&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;realpath&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;curdir&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:49:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196543#M8698</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T09:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196544#M8699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have now tested this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/400322_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As is visible, it returns the path of the Pro project folder (which had the default "MyProject1" for this test), where the Project document (*.aprx) is stored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArcMap, it returns the path to the folder where the ArcMap document (*.mxd) is stored, so that is consistent with the Pro result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/400323_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, these paths do not match with the toolbox folder. If I add the toolbox from a location that is clearly not the same as the folder where the project is stored, ArcMap will still function, as the import statements seem interpreted relative to the toolbox location. In Pro, it fails.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2018 23:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196544#M8699</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-30T23:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196545#M8700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you running the ArcMap tool from ArcToolbox, or from the Catalog window?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I remember now that a while ago I was dinking with this and saw the same thing you did. &amp;nbsp;&amp;nbsp;If the tool is added to ArcToolbox I get a different "home" )ie the tbx's folder) than when run from the Catalog window (the ArcMap Home). I bet you may get a third place if run from ArcCatalog's folder tree.&amp;nbsp; And,&amp;nbsp; sys.argv[0] and __file__ give me an empty string, not the .tbx path when I call them inside the Calculate Value tool. HOWEVER, I&amp;nbsp; just thought of a&amp;nbsp;method to meet your use&amp;nbsp;case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This&amp;nbsp;possibly would work from ArcMap, ArcCatalog, or Pro, Catalog window or ArcToolbox, if you create it in ArcMap. Please try it and let me know&amp;nbsp;if you get anywhere with my idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a small script tool to find the current folder, place the file&amp;nbsp;in the folder containing&amp;nbsp;tbx and your module.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# findhere.py&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dirname&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;realpath&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;__file__&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. Add&amp;nbsp;&lt;STRONG&gt;findhere.py&lt;/STRONG&gt; script to your .tbx. Go to properties, set relative path checkbox in the first tab. Create a Derived parameter in the parameters tab that is type Folder. Name the&amp;nbsp;parameter Folder.&lt;/P&gt;&lt;P&gt;3. Drop this script tool into your model, try&amp;nbsp;running it to get the path to where findhere.py and your modules you want to import are.&lt;/P&gt;&lt;P&gt;4. Create a Calculate Value tool and make the Folder output a precondition to it.&lt;/P&gt;&lt;P&gt;5. Use this&amp;nbsp;Folder variable&amp;nbsp;in your Calculate Value tool with sys.path.insert(0, path), for example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Expression: report()&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Code block:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;insert&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"%Folder%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;## do your import here ##&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;report&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;x&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="400329" alt="model screenshot" class="image-1 jive-image" height="490" src="/legacyfs/online/400329_Screen Shot 2018-03-30 at 11.10.24 PM.png" width="625" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:49:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196545#M8700</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T09:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196546#M8701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the details. Yes, I can see how this inconsistency is annoying. I'm looking into this, and what the ideal behavior is for uses like this. Here are some alternative approaches you can use immediately:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Use an explicit path to your external toolbox for the import. This is brittle since it will be hard coded, but it should work fine for your immediate needs.&lt;/P&gt;&lt;P&gt;2. Copy your code into a module, and place that into the Pro site-packages directory (you can create a setuptools package or conda package for this as well). If you're making something more durable, this is a great way to start creating a library around the code you're using, and then you'll be able to import it elsewhere as well.&lt;/P&gt;&lt;P&gt;3. Add a .pth file which links to the directory where your external toolbox is. You can add this to the Pro site-packages, and it will add that location explicitly to the Python search path (for all processes).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 04:39:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196546#M8701</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2018-03-31T04:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196547#M8702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Curtis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will give this a try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, your solution of course kind of defeats the whole purpose of the &lt;STRONG&gt;Calculate Value&lt;/STRONG&gt; tool, which is to be able to insert and use small Python code snippets inside a geoprocessing model without the need to write a true script and accompanying toolvalidation. If I need to insert a secondary Python script to get the Calculate Value tool to work, I might just as well write it to output the required value the Calculate Value tool was supposed to deliver...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, from a technical point of view, I am interested to see if your solution works, so will report back on that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 08:23:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196547#M8702</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-31T08:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196548#M8703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shaun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, all of these solutions complicate deployment. With ArcMap, you can just drop the toolbox and scripts it uses anywhere on a file system, and it will import and work properly (assuming scripts and toolbox are in the same folder and scripts have been set to use relative paths, which all of mine are).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do more and more feel this should be considered a bug, as it breaks current models running perfectly in ArcMap. It also complicates maintaining dual ArcMap / ArcGIS Pro and Python 2/3 compatible toolboxes (which mine is).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to modules: I actually have written dozens of Python scripts that serve dual roles as geoprocessing tools and modules with functions that I import into other scripts, so as to durability and code maintenance in terms of avoiding code duplication, I think I am OK&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 08:29:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196548#M8703</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-31T08:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196549#M8704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curtis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is &lt;STRONG&gt;&lt;EM&gt;really&lt;/EM&gt; &lt;/STRONG&gt;weird. I now attempted to implement your solution, but it still fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, you learned me something new, as I wasn't aware you could use the "%variable name%" syntax directly in the Code Block of the &lt;STRONG&gt;Calculate Value&lt;/STRONG&gt; tool. I always assumed it could only be used in the Expression text line, and then consumed by a function definition, as that is what the Help shows (and how I implemented it always).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to the failure:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="400331" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/400331_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look in this second image, which shows the top of the messaging output related to the Calculate Value tool, you can see that your code actually worked, and correctly inserted the toolbox's / script's folder path ("C:\OSM_Renderer") in the sys.path statement, just before the import of the module I need to access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="400332" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/400332_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yet, the import still fails!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am highly confused now &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/confused.png" /&gt;. Why does it, if the &lt;STRONG&gt;sys.path&lt;/STRONG&gt; is set? It is almost as if Pro ignores sys.path completely, and only uses and searches in the default Pro Python install for modules... I am absolutely 100% sure I got the module name right. Exactly the same code from the same toolbox runs fine in ArcMap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 09:36:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196549#M8704</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-31T09:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196550#M8705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt; you can just drop the toolbox and scripts&amp;nbsp;&lt;/SPAN&gt; ...&lt;/P&gt;&lt;P&gt;scripts and toolboxes work, just fine in Pro. To clarify, that I haven't misread, your issue is with models and toolboxes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 09:38:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196550#M8705</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-03-31T09:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196551#M8706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;I am stumped... &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/shocked.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;I now realized that my toolbox folder should have a space in it:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #333333; font-size: 15px;"&gt;"C:\OSM Renderer\"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;yet the geoprocessing output shows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;&lt;STRONG&gt;"C:\OSM_Renderer\"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;so with the space replaced with an underscore...&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;I now modified your script to see what is going on:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #808080;"&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; color: #808080;"&gt;import os&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #808080;"&gt;arcpy.AddMessage("BEFORE SetParameterAsText: " + os.path.dirname(os.path.realpath(__file__)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #808080;"&gt;arcpy.SetParameterAsText(0, os.path.dirname(os.path.realpath(__file__)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; color: #808080;"&gt;arcpy.AddMessage("AFTER SetParameterAsText: " + arcpy.GetParameterAsText(0))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;Now look at the output below, and notice how Pro changed the folder name to contain an underscore instead of space... This is wrong! Either &lt;STRONG&gt;SetParameterAsText&lt;/STRONG&gt; or &lt;STRONG&gt;GetParameterAsText&lt;/STRONG&gt; mangles the folder path.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #333333;"&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/400333_pastedImage_5.png" style="width: auto; height: auto;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 11:37:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196551#M8706</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-31T11:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196552#M8707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I replace the original folders name with the version with underscore, and re-run the original tool, &lt;STRONG&gt;&lt;EM&gt;the module is finally properly imported and the tool runs in Pro&lt;/EM&gt;&lt;/STRONG&gt;! However, this should not happen. Pro should not replace spaces with underscores in arcpy.Get- or SetParamaterAsText function calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/400334_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 11:41:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196552#M8707</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-31T11:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro bug?: Can't import custom Python module in "Calculate Value" tool of ModelBuilder</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196553#M8708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curtis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well, this settles it. I have now changed the output parameter type of the &lt;STRONG&gt;GetToolboxFolder&lt;/STRONG&gt; script that I created using your example code from the suggested &lt;STRONG&gt;Folder&lt;/STRONG&gt; to &lt;STRONG&gt;String&lt;/STRONG&gt; parameter type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pro no longer mangles the output, and the custom Python module I wrote and use in the &lt;STRONG&gt;Calculate Value&lt;/STRONG&gt; tool is now found using your suggested code solution. So I have accepted this as the answer with the minor correction that users should set a &lt;STRONG&gt;String&lt;/STRONG&gt; instead of &lt;STRONG&gt;Folder&lt;/STRONG&gt; parameter type output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="400336" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/400336_pastedImage_8.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="400335" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/400335_pastedImage_7.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2018 12:03:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-bug-can-t-import-custom-python-module/m-p/196553#M8708</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2018-03-31T12:03:57Z</dc:date>
    </item>
  </channel>
</rss>

