Riverscapes / pyBRAT

pyBRAT - Beaver Restoration Assessment Tool (Python)
http://brat.riverscapes.xyz
GNU General Public License v3.0
10 stars 10 forks source link

Import Error #316

Closed ZachNFJDWC closed 9 months ago

ZachNFJDWC commented 9 months ago

I am trying to get pyBRAT working in Arcmap 10.8 and am getting the error "ImportError: cannot import name write_xml_element_with_path" on line 18 in BRATProject.py. The weird thing is, I had it working to where I could open up the tools in the toolbox, but needed to run the NHD Network Builder tool from the RCAT toolbox. After I ran it and got the output I needed, I went back to the pyBRAT toolbox and it had the red X through it again. I used the "Check Syntax" option and got the import error mentioned above. Things I've tried: 1. deleting the toolbox and downloading it again 2. changing the code "from SupportingFunctions import make_folder, make_layer, get_execute_error_code, write_xml_element_with_path, find_available_num_prefix" to from "SupportingFunctions import make_folder, make_layer, get_execute_error_code, a, find_available_num_prefix" and then going into the "SupportingFunctions.py" file and changed the name of the "def write_xml_element_with_path(xml_file, base_element, xml_element_name, item_name, path, project_root, xml_id=None):" method to "def a(xml_file, base_element, xml_element_name, item_name, path, project_root, xml_id=None):" to see if it was actually just a typo or something, but came across the same error. 3. Moving the whole pyBRAT folder in and out of other folders and that obviously didn't fix it. 3. I check the code for circular imports, and not surprisingly it looked fine to me.

As I mentioned above, the pyBRAT was working originally and nothing changed to my knowledge, so I think my path of checking the script itself is the wrong way to go. I just recently started learning programming, so I am not really sure what else to check. I consulted ChatGPT and and made a lot of the same suggestions of thing I already did. I checked the python version and file path and got "('Python Version:', '2.7.18.4 (default, Aug 9 2021, 23:37:24) [MSC v.1500 32 bit (Intel)]') ('Python Executable Path:', 'C:\Program Files (x86)\ArcGIS\Desktop10.8\bin\ArcMap.exe')" which seems correct to me. Anyone have any ideas on what to check, do, or what I may have messed up on to cause this? Thanks for any help/advice!

ZachNFJDWC commented 9 months ago

I guess I was using the wrong version of pyBRAT. I download pyBRAT 3.1.0 from https://github.com/Riverscapes/pyBRAT/releases/tag/3.1.00 (where the riverscapes.net pyBRAT download page took me). This time, I tried googling "pyBRAT" and it led me to https://github.com/Riverscapes/pyBRAT which had the latest version. My best guess as to what happened is that I originally had the latest version and the 3.1.0 version (I've spent a decent amount of time monkeying around before even getting to this point) and when I went to get rid of some files, I accidently got rid of the correct version and kept the wrong version. On the off chance that someone runs into the same problem, the correct version came with the name "pyBRAT-master" and the old version was "pyBRAT 3.1.0".