2

As a seasoned user of ArcMap with extensive experience in Python and .tbx development, I've run into a problem while transitioning to ArcGIS Pro. In ArcMap 10.8, any edits I make to my own imported module .py files are reflected as expected when I run scripts; the tools employ the revised code accordingly. However, in ArcGIS Pro, this isn't the case. After making modifications to a module's .py file and re-running .tbx script tools, the new code isn't executed as it should be.

I've tried refreshing the toolboxes and deleting all .pyc files within the module subdirectories, but neither of these methods causes the revised code to be executed. The only workaround I've found thus far is to completely restart ArcGIS Pro, a solution that is far from ideal and negatively impacts development efficiency.

I've searched the internet for solutions, but to no avail. I did come across a similar issue in the Esri Community at Python cache for custom toolbox: why?, but the suggested fix doesn't seem to be feasible for our codebase given the intricate nature of our imports. It seems that reloading modules might not be a practical solution in this case.

4
  • Cross-posted as stackoverflow.com/q/76518523/820534
    – PolyGeo
    Jun 21, 2023 at 19:39
  • I'd recommend editing your question to explain why reload() isn't a viable solution in your case. That's worked fine for me in the past. Jun 21, 2023 at 22:09
  • 1
    @Hugh_Kelley reload(module) is python 2, importlib.reload(module) is the func to use in current python versions.
    – user2856
    Jun 22, 2023 at 1:12
  • >> from importlib import reload >> reload(module) works well in python3 and makes porting easier compared to re-writing each reload. Jun 22, 2023 at 12:19

1 Answer 1

3

I am porting a tool that was an ArcMap addin into the ArcGIS Pro toolbox, so turning my VB code into a Python tool.

I'm writing the code directly into the newer atbx toolbox and importantly have chosen to embed it into the toolbox, so when I have completed my coding phase I can secure the source code with a password.

I was using spyder but latest version of ArcGIS Pro breaks that, banged my head against the wall for weeks and then moved over to VSCode. So when I right click on the tool and choose edit it opens up in VS code. I can keep that open and any edits I do followed by a save are picked up by the tool when I run it. So it all works really well except for one case and that when I have need to edit a module that I import that holds all my util functions. In that case I have to restart ArcGIS Pro.

Hope that helps?

1
  • Thanks for you comment. Unfortunately, the situation that is most difficult for us is the one where we make edits to our own imported modules, in which case we are having to restart ArcPro to get the changes applied. FWIW, our org has generally moved away from importing .py files into the .tbxs for greater flexibility. We have an extensive list of custom ArcMap tools we're trying to update to ArcPro now and this conundrum is a real drag on development time. Jun 21, 2023 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.