I need to find an excel file with certain nomenclature but I'm receiving an odd error:
ppp = pathlib.Path('A:\\bsolute\path_to\dir_being_searched').glob('**/*edit.xlsx')
for iii in ppp:
print(iii.absolute())
This then returns one absolute path to a file (but not the one I want) with the right nomenclature and then errors out with:
FileNotFoundError Traceback (most recent call last)
Input In [19], in <cell line: 2>()
1 ppp = pathlib.Path('A:\\bsolute\path_to\dir_being_searched').glob('**/*edit.xlsx')
----> 2 for iii in ppp:
3 print(iii.absolute())
etc.
File C:\Anaconda3.7\envs\env_name\lib\pathlib.py:558, in _WildcardSelector._select_from(self, parent_path, is_dir, exists, scandir)
556 def _select_from(self, parent_path, is_dir, exists, scandir):
557 try:
--> 558 with scandir(parent_path) as scandir_it:
559 entries = list(scandir_it)
560 for entry in entries:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'A:\\bsolute\\path_to\\dir_being_searched\\more\\dirs'
I'm not sure how, but it looks to me like its finding a file with the glob and then failing to find it again when it goes through the generator. I'm using Python 3.9.10 and this is happening in a jupyter notebook on Windows 10.