Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'importlib' has no attribute 'util' #108

Closed
drewoldag opened this issue Oct 29, 2024 · 7 comments · Fixed by #181
Closed

AttributeError: module 'importlib' has no attribute 'util' #108

drewoldag opened this issue Oct 29, 2024 · 7 comments · Fixed by #181
Assignees
Labels
bug Something isn't working
Milestone

Comments

@drewoldag
Copy link
Collaborator

drewoldag commented Oct 29, 2024

Bug report
@maxwest-uw is working with fibad and kbmod-ml, and ran into this error when trying to push changes. It's clearly lines in Fibad that are causing this:

Traceback (most recent call last):
File "/astro/users/maxwest/fibad_script.py", line 7, in
fibad_instance = fibad.Fibad(config_file="kbmod_fibad_config.toml")
File "/astro/users/maxwest/fibad/src/fibad/fibad.py", line 46, in init
self.config_manager = ConfigManager(runtime_config_filepath=config_file)
File "/astro/users/maxwest/fibad/src/fibad/config_utils.py", line 85, in init
self.external_library_config_paths = self._find_external_library_default_config_paths(
File "/astro/users/maxwest/fibad/src/fibad/config_utils.py", line 136, in _find_external_library_default_config_paths
default_configs |= ConfigManager._find_external_library_default_config_paths(value)
File "/astro/users/maxwest/fibad/src/fibad/config_utils.py", line 140, in _find_external_library_default_config_paths
if importlib.util.find_spec(external_library) is not None:
AttributeError: module 'importlib' has no attribute 'util'

@drewoldag drewoldag added the bug Something isn't working label Oct 29, 2024
@drewoldag drewoldag self-assigned this Oct 29, 2024
@drewoldag
Copy link
Collaborator Author

I spent some time trying to reproduce this locally on the command line and wasn't able to do so. Running the following on my local machine with Python 3.11 was fine:

import importlib
importlib.util.find_spec("asdf")

In some examples of people using find_spec, I see that they typically import the following:

import importlib
import importlib.util
...

So perhaps that is necessary on some systems?

I also took a look through the python code base to see if perhaps importing just importlib would not include util, but it does seem to include it.

So I'll put together a little PR that adds the second import importlib.util statement and we can see if that fixes things.

@drewoldag drewoldag linked a pull request Oct 29, 2024 that will close this issue
@drewoldag drewoldag removed their assignment Dec 13, 2024
@drewoldag
Copy link
Collaborator Author

Closed the PR that was associated with this issue since it's not clear that it's actually addressing the root cause. Will reopen the PR (or close this issue) after I have a chance to do a little more investigation with @maxwest-uw in the coming weeks.

@drewoldag
Copy link
Collaborator Author

I haven't had a chance to review this with @maxwest-uw, will try to do that before Jan 10

@drewoldag drewoldag added this to the v0.2 release milestone Jan 8, 2025
@drewoldag drewoldag self-assigned this Jan 16, 2025
@drewoldag
Copy link
Collaborator Author

I've been working with kbmod_ml for several days now and haven't been able to reproduce this error. Going to close as won't do.

@drewoldag drewoldag closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2025
@drewoldag
Copy link
Collaborator Author

Max is still encountering this issue, so reopening and will fix shortly.

@drewoldag
Copy link
Collaborator Author

drewoldag commented Jan 23, 2025

FWIW, this only seems to crop up when running on the Baldur machine.

@drewoldag
Copy link
Collaborator Author

One final note - I was watching over Max's shoulder when I saw this error pop up. When I attempted to reproduce this in my baldur account in the default python 3.7 environment, it worked fine, but when I switched to an environment with kbmod, it failed.

In default python 9.7 environment

>>> import importlib
>>> importlib.util  # works fine

In kbmod python 9.11 environment

>>> import importlib
>>> importlib.util
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'util'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant