[Solved] Deluge won't start, ubuntu 22.04

General support for problems installing or using Deluge
san.lostsoul
New User
New User
Posts: 5
Joined: Sun Sep 17, 2023 4:07 pm

[Solved] Deluge won't start, ubuntu 22.04

Post by san.lostsoul »

Hello everyone, I'm new here and please excuse my poor english.
I'm using LinuxLite 6.6 based on Ubuntu 22.04 LTS. Deluge worked perfectly, but 3 days ago I buyed an HP M140we MFP and I installed hplip I got from 123.hp.com. Well, after this Deluge won't start. If I try to start from terminal, iI got these response:

Code: Select all

deluge
Traceback (most recent call last):
  File "/usr/bin/deluge", line 33, in <module>
    sys.exit(load_entry_point('deluge==2.1.1', 'gui_scripts', 'deluge')())
  File "/usr/lib/python3/dist-packages/deluge/ui/ui_entry.py", line 140, in start_ui
    ui.start()
  File "/usr/lib/python3/dist-packages/deluge/ui/gtk3/__init__.py", line 45, in start
    from .gtkui import GtkUI
  File "/usr/lib/python3/dist-packages/deluge/ui/gtk3/gtkui.py", line 24, in <module>
    from twisted.internet import defer, gtk3reactor
  File "/usr/lib/python3/dist-packages/twisted/internet/gtk3reactor.py", line 22, in <module>
    from twisted.internet import gireactor
  File "/usr/lib/python3/dist-packages/twisted/internet/gireactor.py", line 27, in <module>
    from twisted.internet import _glibbase
  File "/usr/lib/python3/dist-packages/twisted/internet/_glibbase.py", line 19, in <module>
    from twisted.internet import base, posixbase, selectreactor
  File "/usr/lib/python3/dist-packages/twisted/internet/posixbase.py", line 19, in <module>
    from twisted.internet import error, tcp, udp
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 37, in <module>
    from twisted.internet._newtls import (
  File "/usr/lib/python3/dist-packages/twisted/internet/_newtls.py", line 18, in <module>
    from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
  File "/usr/lib/python3/dist-packages/twisted/protocols/tls.py", line 40, in <module>
    from OpenSSL.SSL import (
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 3279, in <module>
    _lib.OpenSSL_add_all_algorithms()
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
Also the deluge-web do the same. I've reinstalled Deluge, Python3, Python2.7, nothing change.
I think Deluge is the best torrent client I've ever used, so I want to get this working, but I don't now what is happening.
What can I do? Thank you in advance

deluge 2.1.1
libtorrent: 2.0.5.0
Python: 3.10.12
OS: Linux Ubuntu 22.04 jammy
Last edited by san.lostsoul on Tue Sep 19, 2023 1:48 pm, edited 1 time in total.
mhertz
Moderator
Moderator
Posts: 2216
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge won't start, ubuntu 22.04

Post by mhertz »

Google(stackoverflow) states (python3-)cryptography need be downgraded(<39), or (python3-)(py)openssl upgraded(>=21.1.0) to circumvent, where latter just pins older python3-cryptography.

I'm not at my computer now so if need more "handholding" than this, then will add/edit in later if needed, or not beaten by rest good people around here :)
san.lostsoul
New User
New User
Posts: 5
Joined: Sun Sep 17, 2023 4:07 pm

Re: Deluge won't start, ubuntu 22.04

Post by san.lostsoul »

Thank you for the quick reply. So, I've to remove python3, you mean? I think openssl is the latest version

Code: Select all

openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
But I also have the python2.7, can I "convince" Deluge to use that version?
TY again.
mhertz
Moderator
Moderator
Posts: 2216
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge won't start, ubuntu 22.04

Post by mhertz »

I just checked in my ubuntu 22.04.3 test VM, though couldn't reproduce however(deluge/libtorrent from PPA), and python3-cryptography old and unaffected of before mentioned issue.

Can you check your versions of these please:

Code: Select all

$ dpkg-query -W python3-{cryptography,openssl}
python3-cryptography      3.4.8-1ubuntu2
python3-openssl 21.0.0-1
san.lostsoul
New User
New User
Posts: 5
Joined: Sun Sep 17, 2023 4:07 pm

Re: Deluge won't start, ubuntu 22.04

Post by san.lostsoul »

mhertz wrote: Mon Sep 18, 2023 10:39 am [...]
Can you check your versions of these please:

Code: Select all

$ dpkg-query -W python3-{cryptography,openssl}
python3-cryptography      3.4.8-1ubuntu2
python3-openssl 21.0.0-1
Done. This is the result:

Code: Select all

dpkg-query -W python3-{cryptography,openssl}
python3-cryptography	3.4.8-1ubuntu2
python3-openssl	21.0.0-1
Edit: is there a way to get a readable log? I tried but mousepad told me was no UTF-8 :(, and I now I've forget how i did this :((
mhertz
Moderator
Moderator
Posts: 2216
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge won't start, ubuntu 22.04

Post by mhertz »

I'm sorry, it seemingly is another issue than I expected, because we have same versions of these, and I don't experience it here.

I will have to think about it / read-up little more later and if find something, then will post again, but as I cannot reproduce then will be little hard for me then honestly, but hopefully others can come up with something.

The error is pretty clear(just baffled why), so don't think log will help much, but otherwise is 'deluge -L debug -l deluge.log' and/or same with deluged if using that. If instead ment logging terminal commands to file, then append to command-lines '>log.txt' or '&> log.txt' to include errors(non-POSIX, but bash/zsh fine), and then 'cat log.txt' to read if needed, or open in vim/nano to copy/paste, or instead use xclip etc etc.

Edit: I read someone having another error with cryptography despite shouldn't be possible when querying installed version from apt, and he found he had other version locally installed from pip, so could you please to make sure run:

Code: Select all

python3 -c 'import cryptography; print(cryptography.__version__)'
san.lostsoul
New User
New User
Posts: 5
Joined: Sun Sep 17, 2023 4:07 pm

Re: Deluge won't start, ubuntu 22.04

Post by san.lostsoul »

mhertz wrote: Mon Sep 18, 2023 12:33 pm [...]

Edit: I read someone having another error with cryptography despite shouldn't be possible when querying installed version from apt, and he found he had other version locally installed from pip, so could you please to make sure run:

Code: Select all

python3 -c 'import cryptography; print(cryptography.__version__)'
BTW, thank you for your time. Yes I can :)

Code: Select all

python3 -c 'import cryptography; print(cryptography.__version__)'
41.0.3
I think you can reproduce the issue installing hplip, aka HP Smart from (https://support.hp.com/it-it/document/buu00659).
You said u're using a VM, right? Probably you'll get the same issue.
TY again.
Edit: the log as you suggested (https://drive.google.com/file/d/1TXMddo ... sp=sharing)
mhertz
Moderator
Moderator
Posts: 2216
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge won't start, ubuntu 22.04

Post by mhertz »

You're welcome buddy, and thanks for thoroughness(log/command-output etc) :)

Anyway, indeed you have same issue as stated before i.e. you have a pip installed version of python's cryptography, local or global not sure, but separate from the apt installed one, and is triggering this bug.

Probably under ~/.local/lib/python3.10/site-packages/cryptography or /usr/local/lib/python3.10/site-packages/cryptography, but you can check specifically through:

Code: Select all

python3 -c 'import cryptography; print(cryptography.__file__)'
Then can quickly workaround by e.g. renaming that cryptography dir to e.g. end in -bak or alike(if local), but you can uninstall that pip iinstalled and interfering copy with 'pip3 uninstall cryptography', and if not local install(so under /usr/local/xxxxx, and not ~/.local/xxxxx, then instead 'sudo pip3 uninstall cryptography'), well unless you need it for something else, and is done on purpose. There where a change to python/pip and restricting usage of pip from only venvs I believe, but I don't think I had that BEP enabled last I messed with my 22.04 VM, so should work still presumably, unless i'm wrong, or have outdated pip or whatever. I'm not at my computer now, and sounds strange that HP driver should make pip installed python package installs, but i'm not certain - did quick search for hplib and python and nothing showed up in quick look atleast,

Edit: Hmm, that hplib atleast uses python I see in a "what's this" subpage of your link - let me check it out and get back to you later then.

Edit2: Pissing me off honestly, not you, just that the downloaded newest hplib for ubuntu uses removed attribute from python in said distro - I edited the 3 py files as needed, but rerunning deletes and downloads source files again. I have spent too much times on this already, so will look at it probably tomorow. It is in apt repos too btw, though haven't checked if outdated.

Edit3: Sorry my mistake - sourceforge got stuck at finding download mirro, and I pressed the big download button underneath, which gave me anchient version doh - just reproduced, strange, but sorry for mistake and bitching :) Anyway, stopped now because something missing, I hope it's not because I stripped the VM down pretty aggressively, as say missing cups which I have, but will check more tomorow.

Edit4: You're right of-course - I will look more into it tomorrow - don't run my commands, as not full fix I see, sorry.

Edit5: I don't know yet why borked original cryptography install from apt, but here workarounded by 'sudo pip3 uninstall python3-cryptography' followed by 'sudo apt install --reinstall python3-cryptography', latter needed as files missing, despite apt-metadata still there.
mhertz
Moderator
Moderator
Posts: 2216
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Deluge won't start, ubuntu 22.04

Post by mhertz »

I made a bunch edits in preceding post, so will just end with new one.

Hplib runs during install, scanjet deps part, among others 'sudo pip3 install ocrmypdf', which will install another cryptography(v41.0.3) under '/usr/local/lib/python3.10/dist-packages/cryptography', breaking deluge, as need under v41.x.

Easiest fix is to update openssl from pypi, forcing cryptography be downgraded at same time so works i.e. 'sudo pip3 install -U pyopenssl', done.

Btw, yesterday I tried instead uninstall the extra and unsupported-by-deluge cryptography version, with 'sudo pip3 uninstall cryptography', which works, but still breaks deluge, and system, by for some reason additionally deleting dirs of the official python3-cryptography package i.e. '/usr/lib/python3/dist-packages/cryptography*', despite apt still states it's installed fine when queried, so had to fix with reinstalling it through 'sudo apt install --reinstall python3-cryptography'. I don't understand why happens, because the 'sudo pip3 uninstall cryptography' showed it would delete /usr/local/lib/python3.10/dist-packages/cryptography*', two dirs, and nothing else, which I selected yes to, so am guessing this is a bug, but didn't find anything on quick googling of pip3 uninstall functionality in general.

Anyway, use the single line I stated before to fix i.e. sudo pip3 install -U pyopenssl', after hplib install and should be good(can also use the alternative on mention with removing and reinstalling cryptography - or little more crude, simply rename '/usr/local/lib/python3.10/dist-packages/cryptography' to e.g. start with an underscore('_cryptography'), for easy reversal if needed). I did run a few functions from ocrmypdf python module, to make sure still worked with the downgraded cryptography now installed, and worked atleast the few I checked + would show error if pinned unsupported regardless i'm pretty sure. (Edit: Sorry that new pyopenssl don't downgrade cryptography anymore, but make it works instead apparently, so even better).

Thanks for reporting, as never heard about this before, and apologies for not just taking your word for it immediately, as you was correct all along and me wasting time looking elsewhere. Thanks! :)
san.lostsoul
New User
New User
Posts: 5
Joined: Sun Sep 17, 2023 4:07 pm

Re: Deluge won't start, ubuntu 22.04

Post by san.lostsoul »

mhertz wrote: Tue Sep 19, 2023 11:47 am [...]
Easiest fix is to update openssl from pypi, forcing cryptography be downgraded at same time so works i.e. 'sudo pip3 install -U pyopenssl', done.
[...]
Thanks for reporting, as never heard about this before, and apologies for not just taking your word for it immediately, as you was correct all along and me wasting time looking elsewhere. Thanks! :)
Hi, I've just done "sudo pip3 install -U pyopenssl" and damn, it worked! Deluge is now working again! You've just won a couple of good beers :D

Also "Thanks for reporting, as never heard about this before, and apologies for not just taking your word for it immediately, as you was correct all along and me wasting time looking elsewhere. Thanks! :)"

How... really? Are you jocking? :lol: No, no, I want to thank you a lot, you've just made my day!
Thanks again. This broken world needs people like you, with people who want to do the best. Greetings.
Last edited by san.lostsoul on Tue Sep 19, 2023 4:05 pm, edited 1 time in total.
Post Reply