Mason10198 / SkywarnPlus

Empowering Asterisk / app_rpt Nodes with Local Alert Intelligence
GNU General Public License v3.0
58 stars 3 forks source link

Can't Install Dependencies on Debian 12 VM #69

Closed tsawyer closed 11 months ago

tsawyer commented 11 months ago

pip3 install ruamel.yaml requests python-dateutil pydub fails with

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.

Any recommendations before I start hacking? Yes, I am root user.

mjwgeek commented 11 months ago

Question, what are you installing this on? Is this an AllStarLink image? It almost sounds like you are installing it on something else that has a GUI like a desktop version of Debian or Ubuntu or something similar which has a package manager built in.

Mason10198 commented 11 months ago

Debian 12 has introduced a stricter policy to discourage installing Python packages system-wide with pip, which is why you're encountering the error: externally-managed-environment. This policy encourages the use of virtual environments, which are a best practice for Python development and deployment since they prevent package conflicts and permission issues.

You're venturing into undocumented land, since I have yet to install/test SkywarnPlus on Debian 12+. Try this, and please report back your experience:

  1. Dependencies

    Install the required dependencies using the following commands, and set up a Python virtual environment for SkywarnPlus:

    1. Debian 12

    Install system-wide dependencies:

    sudo apt install unzip ffmpeg python3 python3-venv python3-pip

    Set up a virtual environment for SkywarnPlus:

    sudo mkdir -p /usr/local/bin/SkywarnPlus
    sudo chown $USER /usr/local/bin/SkywarnPlus
    python3 -m venv /usr/local/bin/SkywarnPlus/venv
    source /usr/local/bin/SkywarnPlus/venv/bin/activate
    pip install ruamel.yaml requests python-dateutil pydub
    deactivate

    When you want to run scripts that depend on packages in the virtual environment, you must activate it first with the source command as shown above.

  2. Download SkywarnPlus

    Continue with the original instructions for downloading and setting up SkywarnPlus.

    cd /usr/local/bin
    wget https://github.com/Mason10198/SkywarnPlus/releases/latest/download/SkywarnPlus.zip
    unzip SkywarnPlus.zip
    rm SkywarnPlus.zip
  3. Configure Permissions

    Continue with the original permissions configuration.

    cd SkywarnPlus
    chmod +x *.py
  4. Edit Configuration

    Continue with the original configuration editing steps.

    nano config.yaml
  5. Crontab Entry

    You will need to modify the crontab entry to activate the Python virtual environment before running the SkywarnPlus script:

    Open your crontab file using the crontab -e command, and add the following line:

    * * * * * /usr/local/bin/SkywarnPlus/venv/bin/python /usr/local/bin/SkywarnPlus/SkywarnPlus.py

    This will ensure that the correct Python interpreter and dependencies are used when the script runs.

NOTES:

tsawyer commented 11 months ago

I figured out I had to install the Debian packages. The OP is the big clew on that. So...

apt install python3-ruamel.yaml
apt install python3-requests
apt install python3-dateutil
apt install python3-pydub

That did the job. Obviously a one-liner would work but I had to search for and then install the correct package.

I'm up and running. Thanks much for your help and for SkywarnPlus.

Mason10198 commented 11 months ago

If that works OK, then great! Even easier. I can stick that in the README. The instructions I posted here were based on plopping SWP into it's own venv, which I guess is the "right" way to do things nowadays? But that seems excessive for a system that's simply running a node, so I won't complain if it isn't necessary.

Can you verify that SWP operates as intended on your Debian 12 system and let us know, please? 😁

tsawyer commented 11 months ago

Question, what are you installing this on? Is this an AllStarLink image? It almost sounds like you are installing it on something else that has a GUI like a desktop version of Debian or Ubuntu or something similar which has a package manager built in.

No, not an AllStar image, not a Linux Desktop. Just a Debian 12 server netinstall.

tsawyer commented 11 months ago

If that works OK, then great! Even easier. I can stick that in the README. The instructions I posted here were based on plopping SWP into it's own venv, which I guess is the "right" way to do things nowadays? But that seems excessive for a system that's simply running a node, so I won't complain if it isn't necessary.

Can you verify that SWP operates as intended on your Debian 12 system and let us know, please? 😁

Yes, it's operating perfectly w/o doing anything different other than the apt install steps above. I don't do anything other than tail messages so my testing is not exhaustive.

Mason10198 commented 11 months ago

As long as something works, then everything should work. Just wanted to make sure the Python packages worked properly (ruamel is able to open config file, so that's a yes).

I'll update the README. Thanks!

mjwgeek commented 11 months ago

Good stuff!