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

Open
drewoldag opened this issue Oct 29, 2024 · 2 comments
Open

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

drewoldag opened this issue Oct 29, 2024 · 2 comments
Labels
bug Something isn't working

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.

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
Development

Successfully merging a pull request may close this issue.

1 participant