Ubuntu 20.04 / python issue with ngettext

General support for problems installing or using Deluge
amacieli
New User
New User
Posts: 1
Joined: Mon May 04, 2020 8:45 pm

Ubuntu 20.04 / python issue with ngettext

Postby amacieli » Mon May 04, 2020 8:59 pm

Hi - I upgraded an clean 18.04 ubuntu install to 20.04. After installing deluged and deluge-web, I am having issues starting deluge-web, with the error message below generated by systemctl status deluge-webui:

Code: Select all

May 04 12:33:01 testvm systemd[1]: Started Deluge Bittorrent Client Web Interface.
May 04 12:33:01 testvm deluge-web[2128]: Unable to initialize gettext/locale!
May 04 12:33:01 testvm deluge-web[2128]: 'ngettext'
May 04 12:33:01 testvm deluge-web[2128]: Traceback (most recent call last):
May 04 12:33:01 testvm deluge-web[2128]:   File "/usr/lib/python3/dist-packages/deluge/i18n/util.py", line 118, in setup_translat>
May 04 12:33:01 testvm deluge-web[2128]:     builtins.__dict__['_n'] = builtins.__dict__['ngettext']
May 04 12:33:01 testvm deluge-web[2128]: KeyError: 'ngettext'


Versions:
(apt list deluge*) deluge-web/focal,focal,now 2.0.3-2 all [installed]
(python3 -V) Python 3.8.2

Is this a bug in the latest deluge-web version, or a bug in my distribution upgrade?

Cheers,

mhertz
Compulsive Poster
Compulsive Poster
Posts: 865
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Ubuntu 20.04 / python issue with ngettext

Postby mhertz » Tue May 05, 2020 12:43 am

It's an issue that isnt really important of deluge 2.0.3 with py38. To fix, you can ask your distro package maintainer to backport this fix from deluge development branch: https://git.deluge-torrent.org/deluge/c ... 94017e7c85

You can also apply it manually in your local install if wanted, as just need adding two extra characters simply, to a single file, as per commit details above. Smarter probably, as gets overwritten on updates, would be to add an systemd override file, adding 2> /dev/null after the starting of daemon, and for deluge-console, you could add a shell-script named deluge-console in your user bin dir, which needs being added infront of PATH and not after, but which usually is done anyways like that, and then in that add '/usr/bin/deluge-console "$@" 2>dev/null', or simply add that line as alias or shell-function to your bashrc/zshrc, but again, the error can be avoided simply as not important. The preceding tips is from memory, which I did before patch to fix this was added to arch-linux deluge package, and later added upstream to deluge development branch, so sorry if anything wrong in that command as from top of head.

dawciobiel
New User
New User
Posts: 2
Joined: Mon Aug 31, 2020 7:01 am

Re: Ubuntu 20.04 / python issue with ngettext

Postby dawciobiel » Mon Aug 31, 2020 7:13 am

I did the fix on file:
/usr/lib/python3/dist-packages/deluge/i18n/util.py

But still deluge-web doest starting:

Code: Select all

┌─<root @ cerebro in ~>
└─<>──» systemctl start deluge-web


┌─<root @ cerebro in ~>
└─<>──» systemctl status deluge-web
● deluge-web.service - Deluge Bittorrent Client Web Interface
     Loaded: loaded (/etc/systemd/system/deluge-web.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Mon 2020-08-31 09:06:31 CEST; 2s ago
       Docs: man:deluge-web
    Process: 8783 ExecStartPre=/bin/sleep 5 (code=exited, status=0/SUCCESS)
    Process: 8799 ExecStart=/usr/bin/deluge-web -l /var/log/deluge/web.log -L warning (code=exited, status=0/SUCCESS)
   Main PID: 8799 (code=exited, status=0/SUCCESS)

sie 31 09:06:26 cerebro systemd[1]: Starting Deluge Bittorrent Client Web Interface...
sie 31 09:06:31 cerebro systemd[1]: Started Deluge Bittorrent Client Web Interface.
sie 31 09:06:31 cerebro systemd[1]: deluge-web.service: Succeeded.


/var/log/deluge/web.log is empty file.

mhertz
Compulsive Poster
Compulsive Poster
Posts: 865
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Ubuntu 20.04 / python issue with ngettext

Postby mhertz » Mon Aug 31, 2020 8:30 am

That ngettext error, isn't a "showstopper" and just "annoying", and can be pretty much ignored, as just fails something translation related. Just adding this for others reading/encountering it(I ran with it personally for about 6 months myself, before fixed, and just sent the error message to stdout in my scripts/shell-functions).
Anyway, your issue is that you neglected the '-d' daemon option, e.g. this is how my default and working package-supplied deluge-web.service(and override) looks like, which comes direct from upstream(unmodified), as per provided under 'packaging/systemd' dir in deluge source tarball/git-tree):

Code: Select all

martin@arch ~ % sudo systemctl cat deluge-web.service
# /usr/lib/systemd/system/deluge-web.service
[Unit]
Description=Deluge Bittorrent Client Web Interface
Documentation=man:deluge-web
After=network-online.target deluged.service
Wants=deluged.service

[Service]
Type=simple
UMask=027

ExecStart=/usr/bin/deluge-web -d

Restart=on-failure

[Install]
WantedBy=multi-user.target

# /usr/lib/systemd/system/deluge-web.service.d/user.conf
# Override service user
[Service]
User=deluge
Group=deluge
martin@arch ~ %

Official docs for service setup for linux(/systemd): https://deluge.readthedocs.io/en/latest ... rvice.html

dawciobiel
New User
New User
Posts: 2
Joined: Mon Aug 31, 2020 7:01 am

Re: Ubuntu 20.04 / python issue with ngettext

Postby dawciobiel » Mon Aug 31, 2020 10:33 am

I think the problem is with python3.8. When i remove it deluge-web is launched.
Maybe there is some issue with python 3.8 and Ubuntu 20.04 verison.

Right now I'm thinking should i downgrade Ubuntu 20.04 -> 18.04 or... just install fedora :)

mhertz
Compulsive Poster
Compulsive Poster
Posts: 865
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Ubuntu 20.04 / python issue with ngettext

Postby mhertz » Mon Aug 31, 2020 12:44 pm

You for sure need add the '-d' switch, which I before posted tested with and without, and got same "inactive (dead)" message without.

Additionally, then I don't know which patches ubuntu adds and whatnot, but a quick check shows ubuntu 20.04 uses deluge 2.0.3, and for py3.8 with that, needs this pacth from deluge develop branch backported: https://git.deluge-torrent.org/deluge/c ... ed0f2c3206 and needs twisted 19.7.0 or newer, but ubuntu 20.04 seemingly uses 18.9.0. If you can downgrade python, and that's fine for you, then a solution I guess, and else, need propperly find newer twisted, and if cannot find, then I guess you could install/update it through something along: "sudo pip3 install --upgrade twisted".

Just sounds strange that this should've gone unnoticed or atleast unfixed, with such popular distro and app.

I'm not to say what you should do of-course, but if you like your distro, then search the issue some more and you probably find the answer or a workaround i'm guessing. Little drastic imho to change your entire distro/version just for one app, without even researching the issue more, but again, not my call of course and anyway not that the choice of distro usually is that important anyhow imho, but nonetheless. You could install deluge 2.0.4.dev38 from source in worst-case scenario also.

Good luck! :)

Edit: It's reported and looked into atleast i.e. py3.8 deluge2 issues: https://bugs.launchpad.net/ubuntu/+sour ... ug/1876955

lukeskywalker
New User
New User
Posts: 1
Joined: Tue Sep 01, 2020 8:13 pm

Re: Ubuntu 20.04 / python issue with ngettext

Postby lukeskywalker » Mon Sep 07, 2020 9:33 pm

I have the same issue. All I did was to run the following on a fresh Ubuntu 20.04.1 machine:

7 apt update
8 apt upgrade
9 reboot
10 apt-get install deluged deluge-web deluge-console
11 groupadd deluge
12 adduser -r -home-dir /var/lib/deluge -g deluge deluge
13 adduser --system --group deluge
14 adduser root deluge
15 nano /etc/systemd/system/deluged.service
16 systemctl start deluged
17 systemctl status deluged
18 systemctl enable deluged
19 nano /etc/systemd/system/deluge-web.service
20 systemctl start deluge-web
21 systemctl status deluge-web


* deluge-web.service - Deluge Bittorrent Client Web Interface
Loaded: loaded (/etc/systemd/system/deluge-web.service; disabled; vendor preset>
Active: inactive (dead)

Sep 07 20:58:12 deluge systemd[1]: Started Deluge Bittorrent Client Web Interface.
Sep 07 20:58:12 deluge deluge-web[1430]: Unable to initialize gettext/locale!
Sep 07 20:58:12 deluge deluge-web[1430]: 'ngettext'
Sep 07 20:58:12 deluge deluge-web[1430]: Traceback (most recent call last):
Sep 07 20:58:12 deluge deluge-web[1430]: File "/usr/lib/python3/dist-packages/delu>
Sep 07 20:58:12 deluge deluge-web[1430]: builtins.__dict__['_n'] = builtins.__di>
Sep 07 20:58:12 deluge deluge-web[1430]: KeyError: 'ngettext'
Sep 07 20:58:12 deluge systemd[1]: deluge-web.service: Succeeded.

-------------
I would very much disagree with someone saying it's not a showstopper. All Ubuntu people trying to install Deluge will face this issue on a headless install trying to get deluged to work through the web ui. Please try to think users as customers and put yourself in their shoes. We tech savvy guys who can pipe things to /dev/null and create symlinks in /usr/bin to patch things up.... come on. Let's raise the bar and make Deluge great again! (no pun intended) :)
PS. I haven't tried out all the fixes stated above yet. I'm on the 5th 'buntu install as I'm not a leet haxx0r slashing the fingers on the board and it suddenly works.

mhertz
Compulsive Poster
Compulsive Poster
Posts: 865
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Ubuntu 20.04 / python issue with ngettext

Postby mhertz » Mon Sep 07, 2020 10:28 pm

I'm sorry, I meant that the ngettext issue isn't a showstopper in the meaning that it literally doesn't "stop the show" i.e deluge, and just hinders something not really important(localization I believe).

There's issues with log functionality/spam etc, when not using new twisted and a backported patch on py3.8, but if memory serves me right then again not a showstopper.

Have you checked that -d is added in the ExecStart command-line for deluge and deluge-web under: etc/systemd/system/deluged.service and deluge-web.service there, which is what can give the error status type, poster before you posted.

If not working still, I can try give you directions to install latest deluge dev-release in a virtualenv(fixes the py3.8 issues, though again, I believe they only spammed log and terminal, and didn't fully break running, but whatever). As posted before, there's an error ticket still open and unresolved, where it's mentioned that downgrading to previous python 3.7 helps like previous poster also stated.

mhertz
Compulsive Poster
Compulsive Poster
Posts: 865
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Ubuntu 20.04 / python issue with ngettext

Postby mhertz » Tue Sep 08, 2020 11:29 pm

OK, as had read this issue several times by know, here and elsewhere, and as honestly thought it cannot be right that we as comunity not even can help users struggling with getting latest deluge running in the most popular linux distro's latest version, then I downloaded and fired up the ubuntu 20.04 livecd in a VM, and looked what was going on.

First, the posted error message was in-fact as I stated before not a showstopper, since if you start it manually e.g. 'deluged, deluge-web', then you get that exact error on terminal, though can access deluged now fine from either consoleUI or web-browsers 'localhost:8112' URL.

Second, deluged is installed with an added debian-deluged user(instead of regularly used 'deluge'), with a homedir defined under '/var/lib/deluged', so when running deluged and deluge-web from service-files or just manually from 'sudo -u debian-deluged deluged' and 'sudo -u debian-deluged deluge-web', then config files are located under '/var/lib/deluged/.config/deluge'.

Now with that out of the way, deluge-web doesn't come with any service file from debian, but deluged gets one auto-generated, under /run/systemd/generator.late/deluged.service, by systemd-sysv-generator, and that is set to load an old sys-v-style deluge service under '/etc/init.d/deluge'.

To get systemd services working and not have to manually start deluge daemons, then follow official docs on how to make them here: https://deluge.readthedocs.io/en/latest ... rvice.html , but you don't need the commands for making user/group, as already done, and just copy/paste service and user.conf files in-place and use the user-name/group 'debian-deluged', well unless wanting to make another user/group, then just follow everything. You can also ditch the user.conf in override folder by instead adding two extra sections under [Service] like this: 'User=debian-deluged' and 'Group=debian-deluged'.

Afterwards run: 'sudo systemctl daemon-reload' and then afterwards 'sudo systemctl enable --now deluged.service' and 'sudo systemctl enable --now deluge-web' - I believe they can both be on one line also, but whatever. Note, this won't work, and sorry for weird order of instructions lol, because of the auto-generated strangeness of the deluged service, but I didn't have time anymore to experiment or read up on how to fully overcome, but fastest workaround I found, was to use other name for the deluged.service, though you can keep the name for the deluge-web, e.g. in my case I just named the deluged.service file for 'delu.service'(in hindsight you could use the name 'deluge.service', though doesn't matter as long as just different) and enabled that. It's strange because when checking with 'sudo systemctl cat deluged.service', back before I changed the name, then the content shown was the new file I copy/pasted from official docs, but still didn't work, also same if running 'sudo systemctl edit --full deluged.service', but as said quick workaround was to rename service file simply, so left it at that. Also, had to rehash terminal/shell at a point('hash - r' in bash, or open new terminal) as even with 'sudo systemctl daemon-reload' then I couldn't start or enable the added service file with new name(delu.service) as wasent found.

They use twisted 18.9 which is the minimum version to use which has logging fixed for py3.8 if I remember right, but you still need a backported patch from deluge develop which I don't think they include yet, but there's open ticket for it on there bugtracker, but that is just spam in the log and will work still, and as said, the ngettext error can be ignored too.

Hope this helps :)

Edit: You can keep the deluged.service name by after adding the service files running: 'sudo systemctl disable --now deluged', and there-after 'sudo systemctl enable --now deluged deluge-web'. You don't need the daemon-reload command either. The first command will also behind the scenes disable the sysv-auto-generator from making the faulty deluge service upon every boot, which won't happen if only adding the service file and running daemon-reload afterwards. As said the first command needs the added service files in-place already, as if not, then the '--now' switch doesn't work, and instead you have to specifically afterwards run 'sudo systemctl stop deluged', before running the next command, but not needed if following the instructions.

Sumerized full instructions(after installing deluge):

Code: Select all

sudo wget -O /etc/systemd/system/deluged.service tiny.cc/6t8zsz
sudo wget -O /etc/systemd/system/deluge-web.service tiny.cc/dt8zsz
sudo systemctl disable --now deluged
sudo systemctl enable --now deluged deluge-web

(You can skip first two commands if already having made the service files yourself and where just the ones I uploaded for easy resuming livecd testing by just wget'ing in-place, and so might as well share here also - includes debian-deluged as user/group definitions, so don't need user.conf, override-dirs or added user/group commands)
Last edited by mhertz on Sun Oct 11, 2020 5:16 pm, edited 1 time in total.

Ruined1
New User
New User
Posts: 1
Joined: Sat Oct 10, 2020 3:08 am

Re: Ubuntu 20.04 / python issue with ngettext

Postby Ruined1 » Sat Oct 10, 2020 3:10 am

Just add

Code: Select all

-d
to your

Code: Select all

/usr/bin/deluge-web


Code: Select all

/usr/bin/deluge-web -d


Return to “Support”

Who is online

Users browsing this forum: No registered users and 13 guests