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

imp no longer exists in 3.12 #195

Open
clausing opened this issue Feb 9, 2024 · 4 comments
Open

imp no longer exists in 3.12 #195

clausing opened this issue Feb 9, 2024 · 4 comments
Assignees
Labels
Enhancement Making an existing feature or parser better Parser Related to Unfurl's parsing capabilities

Comments

@clausing
Copy link

clausing commented Feb 9, 2024

Description
Import from imp fail since imp is no longer supported in python 3.12. Generates lots of the the following error(s)

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/unfurl/core.py", line 319, in run_plugins
    parser = importlib.import_module(f'unfurl.parsers.{unfurl_parser}')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/local/lib/python3.12/site-packages/unfurl/parsers/parse_mac_addr.py", line 15, in <module>
    import maclookup
  File "/usr/local/lib/python3.12/site-packages/maclookup/__init__.py", line 5, in <module>
    from .api_client import ApiClient
  File "/usr/local/lib/python3.12/site-packages/maclookup/api_client.py", line 2, in <module>
    from future.standard_library import install_aliases
  File "/usr/local/lib/python3.12/site-packages/future/standard_library/__init__.py", line 65, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'```


@clausing clausing added Enhancement Making an existing feature or parser better Parser Related to Unfurl's parsing capabilities labels Feb 9, 2024
@clausing clausing changed the title imp no longer exists in 3.1 imp no longer exists in 3.12 Feb 9, 2024
@obsidianforensics obsidianforensics self-assigned this Jun 28, 2024
@obsidianforensics
Copy link
Owner

I believe this is caused by the maclookup package, which looks like it hasn't been updated since 2018(!) and doesn't work well with Python 3.12. I'll look at finding a different way to provide this functionality.

@eljeffeg
Copy link

eljeffeg commented Jul 19, 2024

Speaking of maclookup, we ran into issues using the pip install as it didn't include the maclookup requirement. Maybe the requirement.txt should include all modules and then have other files if you want a slim version? Or maybe wrap the import in a Try / Except as an optional component. We're not even using the maclookup afaik, but would get this error.

File "/home/user/.local/lib/python3.12/site-packages/unfurl/parsers/parse_mac_addr.py", line 15, in <module>
    import maclookup
ModuleNotFoundError: No module named 'maclookup'

But yeah, replacing it all together may be good idea.

@eljeffeg
Copy link

Perhaps doing this might avoid it as a main application requirement by only importing it if it's actually used.

elif node.data_type == 'mac-address' and unfurl.api_keys.get('macaddress_io') and unfurl.remote_lookups:
        import maclookup
        client = maclookup.ApiClient(unfurl.api_keys.get('macaddress_io'))

@eljeffeg
Copy link

Looks like there are several alternatives or could probably just use requests and hit the REST API directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Making an existing feature or parser better Parser Related to Unfurl's parsing capabilities
Projects
None yet
Development

No branches or pull requests

3 participants