Migration 0017_postgresql_9p6_to_11 did not complete, aborting. Error: a bytes-like object is required, not 'str'

Hi all,

Just for the record if anyone have the same problem, let me mention an issue with 2 migration scripts, postgresql_9p6_to_11 and 0018_xtable_to_nftable (maybe executed a bit late…). Here is the log and solution to apply :

2021-05-14 16:41:43,789: INFO - Running migration 0017_postgresql_9p6_to_11...
2021-05-14 16:41:43,790: DEBUG - Running command: dpkg --list | grep '^ii ' | grep -q -w postgresql-9.6
2021-05-14 16:41:43,826: ERROR - Migration 0017_postgresql_9p6_to_11 did not complete, aborting. Error: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/usr/lib/moulinette/yunohost/tools.py", line 1003, in tools_migrations_run
    migration.run()
  File "/usr/lib/moulinette/yunohost/data_migrations/0017_postgresql_9p6_to_11.py", line 21, in run
    if not self.package_is_installed("postgresql-9.6"):
  File "/usr/lib/moulinette/yunohost/data_migrations/0017_postgresql_9p6_to_11.py", line 56, in package_is_installed
    raise_on_errors=False,
  File "/usr/lib/moulinette/yunohost/data_migrations/0017_postgresql_9p6_to_11.py", line 81, in runcmd
    out = out.strip().split("\n")
TypeError: a bytes-like object is required, not 'str'
2021-05-14 16:41:43,849: INFO - Running migration 0018_xtable_to_nftable...
2021-05-14 16:41:43,864: DEBUG - Running command: iptables-legacy -L >/dev/null
2021-05-14 16:41:43,871: ERROR - Migration 0018_xtable_to_nftable did not complete, aborting. Error: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/usr/lib/moulinette/yunohost/tools.py", line 1003, in tools_migrations_run
    migration.run()
  File "/usr/lib/moulinette/yunohost/data_migrations/0018_xtable_to_nftable.py", line 40, in run
    "iptables-legacy -L >/dev/null"
  File "/usr/lib/moulinette/yunohost/data_migrations/0018_xtable_to_nftable.py", line 125, in runcmd
    out = out.strip().split("\n")
TypeError: a bytes-like object is required, not 'str'

It happens if the switch to Python 3 has been made previously. You only have to change out = out.strip().split("\n") to out = out.strip().split(b"\n") in both scripts and rerun migration tools.

Cheers!

I also have this problem

Change out = out.strip().split("\n") to out = out.strip().split(b"\n") line 81 in /usr/lib/moulinette/yunohost/data_migrations/0017_postgresql_9p6_to_11.py file and line 125 in /usr/lib/moulinette/yunohost/data_migrations/0018_xtable_to_nftable.py script. Then run again migration tools and it should work.

2 Likes

Thank you! It worked!

Thanks also !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.