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

import imp fails in Python 3.12 replace with importlib #2226

Closed
Harding-Stardust opened this issue Dec 22, 2023 · 10 comments
Closed

import imp fails in Python 3.12 replace with importlib #2226

Harding-Stardust opened this issue Dec 22, 2023 · 10 comments

Comments

@Harding-Stardust
Copy link

Describe the Bug


fails since

The imp module has been removed. (Contributed by Barry Warsaw in gh-98040.)

Source: https://docs.python.org/3.12/whatsnew/3.12.html

Change:
https://github.com/Tautulli/Tautulli/blob/d019efcf911b4806618761c2da48bab7d04031ec/lib/future/standard_library/__init__.py#L300C11-L300C11

to

module_info = importlib.util.find_spec(name, path)

and
https://github.com/Tautulli/Tautulli/blob/d019efcf911b4806618761c2da48bab7d04031ec/lib/future/standard_library/__init__.py#L301C9-L301C9

to

return importlib.import_module(name, *module_info)

Steps to Reproduce

  1. Clean install of Python 3.12
  2. Manually download Tautulli
  3. Try to start with python Tautulli.py

Expected Behavior

Tautulli should start

Screenshots

No response

Relevant Settings

Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]

Tautulli Version

2.13.4

Git Branch

release

Git Commit Hash

NA

Platform and Version

Windows 10

Python Version

3.12.1

Browser and Version

NA

Link to Logs

NA

@Harding-Stardust Harding-Stardust changed the title import imp fails in Python 3.21, replace with importlib import imp fails in Python 3.12 replace with importlib Dec 23, 2023
@jpezzulli
Copy link

I am awaiting a fix on this. Willing to donate to make this a priority. just let me know.

@smorriso
Copy link

I am awaiting a fix on this. Willing to donate to make this a priority. just let me know.

If you feel confident, I just commented out the offending line and it worked fine as a workaround.
sudo -u tautulli vim /opt/Tautulli/lib/future/standard_library/init.py

import logging
#import imp <--- HERE
import contextlib

@hunterzero99
Copy link

I am awaiting a fix on this. Willing to donate to make this a priority. just let me know.

If you feel confident, I just commented out the offending line and it worked fine as a workaround. sudo -u tautulli vim /opt/Tautulli/lib/future/standard_library/init.py

import logging #import imp <--- HERE import contextlib

It might be better to replace import imp with import importlib instead of commenting it out.

@jpezzulli
Copy link

jpezzulli commented Apr 30, 2024 via email

@aparker-cityworks
Copy link

Archlinux is now utilizing Python 3.12. Would love if this could be fixed.

@gituser765
Copy link

I am awaiting a fix on this. Willing to donate to make this a priority. just let me know.

If you feel confident, I just commented out the offending line and it worked fine as a workaround. sudo -u tautulli vim /opt/Tautulli/lib/future/standard_library/init.py
import logging #import imp <--- HERE import contextlib

It might be better to replace import imp with import importlib instead of commenting it out.

thanks, this helped me fix the issue until the new version is pushed out for arch users who installed via AUR

sudo nano /usr/lib/tautulli/lib/future/standard_library/init.py

change "import imp" to "import importlib"

save

sudo systemctl stop tautulli.service
sudo systemctl start tautulli.service

@IdyllicHappiness
Copy link

Ah, wish I'd seen these comments before doing my fix, glad to see it works, looks a lot easier!

I wasn't sure if there was a drop-in replacement module, and how many places it would need to be changed in, so I made a custom service to keep using Python 3.11 (with pyenv installed).

mkdir /usr/local/bin/pyenv-global/ \
&& PYENV_ROOT=/usr/local/bin/pyenv-global pyenv install 3.11.9  \
&& cp /usr/lib/systemd/system/tautulli.service /etc/systemd/system/tautulli-custom-python311.service

# Edit /etc/systemd/system/tautulli-custom-python311.service to use "/usr/local/bin/pyenv-global/versions/3.11.9/bin/python" instead of /usr/bin/python

systemctl daemon-reload \
&& systemctl disable --now tautulli.service \
&& systemctl enable --now tautulli-custom-python311.service

Copy link

This bug has been fixed and will be available in the next release of Tautulli. This issue will be automatically closed once the update is available.

@mmozeiko
Copy link

Is the change being fixed part of #2098 ?
Because I don't think it has proper fix. I see change in lib/future/standard_library/__init__.py file from import imp to import importlib as imp - https://github.com/Tautulli/Tautulli/pull/2098/files#diff-8c5a040d7aebfafa50fbe81017109d16cf80d41c71296222991286bcfca0d8b6R66-R70

But the usage of imp is not changed - https://github.com/Tautulli/Tautulli/blob/nightly/lib/future/standard_library/__init__.py#L306-L307
importlib module is not compatible with imp - it does not have find_module or load_module functions. See here: https://docs.python.org/3/library/importlib.html#functions

@JonnyWong16
Copy link
Contributor

python-future fixed support for Python 3.12.

https://github.com/PythonCharmers/python-future/releases/tag/v1.0.0

The lines you reference do not affect it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

9 participants