Debian 12 pip pipx install error

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
road hazard
Newbie
Newbie
Posts: 12
Joined: August 10th, 2019, 8:48 pm

Debian 12 pip pipx install error

Post by road hazard »

First, I wasn't sure which section to put this in. It's not a problem with the Debian package but IS a problem with Debian 12. So mods, if this is the wrong spot, feel free to move it. Sorry :)

Been using SAB on my Debian 11 box for a few years with zero problems. I was able to follow all the instructions just fine and it has been humming along.

Before I upgrade my main server to Debian 12, I installed it on a test system and am installing all the programs I use (Plex, Emby, Sonarr, Radarr and SAB) to make sure I won't break anything.

Everything was going perfectly until I got to SAB :( I know that Debian made some changes to the pip stuff (pipx now) and when trying to install SAB, I ran into this problem:

Code: Select all

pip install --upgrade -r requirements.txt

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
While I -have- been using Linux for a few years, I'm by no means an expert and can't figure out how to proceed. Should I use '--break-system-packages' or the fix right in front of my eyes?

Code: Select all

python3 -m venv path/to/venv.

Then use path/to/venv/bin/python and path/to/venv/bin/pip.
Just want to go the best route to ensure SAB works 100%. I understand what the Debian devs are saying about why they changed things...... isolating pip stuff so it doesn't break some critical python package....... but in the years I've been using Debian 10/11, the "old way" with pip never broke anything. :)
road hazard
Newbie
Newbie
Posts: 12
Joined: August 10th, 2019, 8:48 pm

Re: Debian 12 pip pipx install error

Post by road hazard »

So I tried following the instructions in the README.venv file and failed miserably. I'm too embarrassed to type out what I tried so does anyone know the correct commands and folders to create to get this working?
User avatar
sander
Release Testers
Release Testers
Posts: 9258
Joined: January 22nd, 2008, 2:22 pm

Re: Debian 12 pip pipx install error

Post by sander »

Yeah. That's food for discussion on different forums. In general, I see more Compartmentalization: docker, snap, flatpak, venv.

I bit the bullet and tried python venv for the first time ... and it wasn't difficult. See my notes on viewtopic.php?t=26235

So I would go that way: venv. After all, Debian people can't be wrong!
User avatar
sander
Release Testers
Release Testers
Posts: 9258
Joined: January 22nd, 2008, 2:22 pm

Re: Debian 12 pip pipx install error

Post by sander »

Just 4 commands, and it works:

Code: Select all

root@e6118656fbc8:~# python3 -m venv ~/my-sabnzbd-venv

root@e6118656fbc8:~# source ~/my-sabnzbd-venv/bin/activate

(my-sabnzbd-venv) root@e6118656fbc8:~# python3 -m pip install -r /sabnzbd-4.0.2/requirements.txt

(my-sabnzbd-venv) root@e6118656fbc8:~# python3 /sabnzbd-4.0.2/SABnzbd.py
Note: change the directories to your needs
User avatar
sander
Release Testers
Release Testers
Posts: 9258
Joined: January 22nd, 2008, 2:22 pm

Re: Debian 12 pip pipx install error

Post by sander »

Full sequence, on a fresh debian:bookworm docker, with the venv inside the SABnzbd directory ... maybe cleaner to do it that way:

Preparation

Code: Select all

apt update
apt install python3-venv wget -y 
wget https://github.com/sabnzbd/sabnzbd/releases/download/4.0.2/SABnzbd-4.0.2-src.tar.gz
tar xvzf SABnzbd-4.0.2-src.tar.gz 
cd SABnzbd-4.0.2
python3 -m venv my-sabnzbd-venv
Activate the venv, install requirements, and run SABnzbd:

Code: Select all

source my-sabnzbd-venv/bin/activate
python3 -m pip install -r requirements.txt 
python3 SABnzbd.py -b0 -l2
Leave the venv:

Code: Select all

deactivate 
Next time run it like this

Code: Select all

source my-sabnzbd-venv/bin/activate
python3 SABnzbd.py -b0 -l2
road hazard
Newbie
Newbie
Posts: 12
Joined: August 10th, 2019, 8:48 pm

Re: Debian 12 pip pipx install error

Post by road hazard »

sander wrote: June 11th, 2023, 10:37 am Full sequence, on a fresh debian:bookworm docker, with the venv inside the SABnzbd directory ... maybe cleaner to do it that way:

Preparation

Code: Select all

apt update
apt install python3-venv wget -y 
wget https://github.com/sabnzbd/sabnzbd/releases/download/4.0.2/SABnzbd-4.0.2-src.tar.gz
tar xvzf SABnzbd-4.0.2-src.tar.gz 
cd SABnzbd-4.0.2
python3 -m venv my-sabnzbd-venv
Activate the venv, install requirements, and run SABnzbd:

Code: Select all

source my-sabnzbd-venv/bin/activate
python3 -m pip install -r requirements.txt 
python3 SABnzbd.py -b0 -l2
Leave the venv:

Code: Select all

deactivate 
Next time run it like this

Code: Select all

source my-sabnzbd-venv/bin/activate
python3 SABnzbd.py -b0 -l2
Thank you so much, that worked! I wonder if this can be added to the official install documentation? (Maybe a special section for Debian 12 since they have switched to using venv's for pip?)

Next question, how do I make this auto-start at boot? On my Debian 11 system, in the 'Startup Applications' applet, I have an entry for 'SABNZBD' and this is the command I use:

Code: Select all

/usr/bin/python3 /mnt/m2ssd/sabnzbd/SABnzbd.py
User avatar
sander
Release Testers
Release Testers
Posts: 9258
Joined: January 22nd, 2008, 2:22 pm

Re: Debian 12 pip pipx install error

Post by sander »

I wonder if this can be added to the official install documentation? (Maybe a special section for Debian 12 since they have switched to using venv's for pip?)
Ubuntu 23.04 also requires it.
And, yes, it must be in the documentation. And possibly a script in the SAB scource code that takes care of it?
how do I make this auto-start at boot?
Two ways:
* install the SABnzbd PPA (see https://sabnzbd.org/wiki/installation/i ... buntu-repo) and follow that instruction to make sab auto-start. Then in /etc/init.d/sabnzbdplus change DAEMON= to something you want
* ugly: use crontab, with a line like:

Code: Select all

@reboot sleep 60 && my_script.sh
So: after reboot, sleep 60 second, then start script
road hazard
Newbie
Newbie
Posts: 12
Joined: August 10th, 2019, 8:48 pm

Re: Debian 12 pip pipx install error

Post by road hazard »

sander wrote: June 11th, 2023, 2:27 pm
I wonder if this can be added to the official install documentation? (Maybe a special section for Debian 12 since they have switched to using venv's for pip?)
Ubuntu 23.04 also requires it.
And, yes, it must be in the documentation. And possibly a script in the SAB scource code that takes care of it?
how do I make this auto-start at boot?
Two ways:
* install the SABnzbd PPA (see https://sabnzbd.org/wiki/installation/i ... buntu-repo) and follow that instruction to make sab auto-start. Then in /etc/init.d/sabnzbdplus change DAEMON= to something you want
* ugly: use crontab, with a line like:

Code: Select all

@reboot sleep 60 && my_script.sh
So: after reboot, sleep 60 second, then start script
Whoops, my bad. I meant to say that the way I'm launching SAB at boot time now (via the 'Startup Applications' applet) in Debian 11 works perfectly. I can't figure out how to get SAB to auto-start at boot now that Debian 12 makes you use a pip venv.
User avatar
sander
Release Testers
Release Testers
Posts: 9258
Joined: January 22nd, 2008, 2:22 pm

Re: Debian 12 pip pipx install error

Post by sander »

I don't know 'Startup Applications', so I can't help with that.
road hazard
Newbie
Newbie
Posts: 12
Joined: August 10th, 2019, 8:48 pm

Re: Debian 12 pip pipx install error

Post by road hazard »

sander wrote: June 12th, 2023, 1:00 am I don't know 'Startup Applications', so I can't help with that.
No worries. If I type these 2 commands, individually:

Code: Select all

source my-sabnzbd-venv/bin/activate
python3 SABnzbd.py -b0 -l2
..... SAB works perfectly. I just need to find a way to automate typing those 2 commands at boot time.
jad-seifeddine
Newbie
Newbie
Posts: 1
Joined: August 12th, 2023, 6:02 pm

Re: Debian 12 pip pipx install error

Post by jad-seifeddine »

You can simply create a shell script and execute at boot
Post Reply