Sabnzbd: FWIW: python3.9 gives "AttributeError: module 'base64' has no attribute 'decodestring'"

Created on 19 May 2020  路  4Comments  路  Source: sabnzbd/sabnzbd

I read Python 3.9 is in beta (https://www.heise.de/news/Python-3-9-startet-in-die-Beta-Phase-4724615.html), I tried on a Ubuntu 20.04 docker image with SABnzbd.

Results. Might be things deprecated / removed in python 3.9, or PIP repo or library not yet in order, or plain PEBKAC, or ...

Maybe safe to specify and check python version should be 3.5, 3.6, 37, 3.8. And not lower, and not higher.

root@67a8e8e36eaa:~# python3.9 /usr/bin/sabnzbdplus
Traceback (most recent call last):
  File "/usr/bin/sabnzbdplus", line 42, in <module>
    import feedparser
  File "/usr/lib/python3/dist-packages/feedparser.py", line 93, in <module>
    _base64decode = getattr(base64, 'decodebytes', base64.decodestring)
AttributeError: module 'base64' has no attribute 'decodestring'

and in the git directory:

root@67a8e8e36eaa:/git/sabnzbd# python3.9 -m pip install -r requirements.txt -U
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'

Calling the above command with python3.8 works OK.

image

root@67a8e8e36eaa:~# python3.8 -c "import base64; print(base64.decodestring) "
<function decodestring at 0x7f7d69e198b0>
root@67a8e8e36eaa:~#
root@67a8e8e36eaa:~#
root@67a8e8e36eaa:~# python3.9 -c "import base64; print(base64.decodestring) "
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'base64' has no attribute 'decodestring'
root@67a8e8e36eaa:~#

Ah: https://docs.python.org/3/library/base64.html tells it:

base64.decodestring(s)露
Deprecated alias of decodebytes().

Deprecated since version 3.1.

Most helpful comment

All 4 comments

I solved the

ModuleNotFoundError: No module named 'distutils.util'

with

apt-get install python3.9-distutils

fatal error: Python.h: No such file or directory

solved with

apt-get install python3.9-dev

And
fatal error: ffi.h: No such file or directory

solved with

apt install libffi-dev libssl-dev

And now python3.9 -m pip install -r requirements.txt -U is OK.

Ah, already known!

Monkey patch:

sed -i 's/base64.decodestring/base64.decodebytes/g' /usr/lib/python3/dist-packages/feedparser.py

and ... SAB runs with python3.9:

# python3.9 SABnzbd.py -s 0.0.0.0:8888
2020-05-19 18:18:34,509::INFO::[SABnzbd:1089] --------------------------------
2020-05-19 18:18:34,510::INFO::[SABnzbd:1090] SABnzbd.py-3.0.0-develop (rev=unknown)
2020-05-19 18:18:34,510::INFO::[SABnzbd:1091] Full executable path = /git/sabnzbd/SABnzbd.py
2020-05-19 18:18:34,510::INFO::[SABnzbd:1101] Platform = posix
2020-05-19 18:18:34,510::INFO::[SABnzbd:1102] Python-version = 3.9.0b1 (default, May 19 2020, 01:22:54)
[GCC 9.3.0]
2020-05-19 18:18:34,511::INFO::[SABnzbd:1103] Arguments = "SABnzbd.py" "-s" "0.0.0.0:8888"

Nice.

image

Final note:

The below was needed to get sabyenc3 working / available in Python 3.9:

apt-get install python3.9-distutils
apt-get install python3.9-dev
apt install libffi-dev libssl-dev
python3.9 -m pip install sabyenc3 --upgrade --force-reinstall
python3.9 -c "import sabyenc3; print(sabyenc3.__version__)" 

With find / -name '*sabyenc3*' you'll see sabyenc3 in both python3.8 and python3.9 directories.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pinn73 picture pinn73  路  5Comments

scriptzteam picture scriptzteam  路  6Comments

JagandeepBrar picture JagandeepBrar  路  5Comments

marka65 picture marka65  路  12Comments

OneCDOnly picture OneCDOnly  路  10Comments