Is it possible to install and run Python 3.11 script in virtual environment?

I use KDE Plasma, and I use goes16-background as a wallpaper.
“goes16-background is a Python 3 script that fetches near-realtime (~15 minutes delayed) image of Earth as its taken by GOES-16 satellite and sets it as your desktop background.”

goes16-background starts and works smoothly with python 3.11.2 (for example) and cannot work at all with python versions 3.11.9-3.12.xx.

Manjaro uses python 3.12.xx now, so I cannot use the script.

I try to install python 3.11.2 and create a virtual environment for it, activate it, but when I start goes16-background, it fails and shows that it still uses python 3.12.xx.

I don’t know what I’m doing wrong. Can anybody help me. Is it possible at all to install and run goes16-background within python 3.11.2 virtual environment on Manjaro? What is the right way to make and use environment for python 3.11.2? I looked through a number of articles on a variety of websites, but got no meaningful explanation.

1 Like

You could install python311 via pyenv. Depending how you start the package, you must use the virtual env’s python executable. Is it a desktop file?

(However, I doubt the quality of the software, if it works with 3.11.2 but not 3.11.9).

Edit: I did just try and running python -m goes16background sets the background correctly :person_shrugging: What is the error you’re seeing?

2 Likes

Thank you for the reply.

  1. The script is old and it seems the creator is reluctant to update it. I sent him a number of letters, but he did not react. Nevertheless, the idea is beautiful and I like the real Earth in the background.
  2. I cannot inform you about the error, because I’m reinstalling everything on that PC now. But the error is long. It mentions python 3.12 many times, line number so and so , line number so and so, and bla, bla, bla.
  3. I’m really a novice, so my knowledge of python virtual environment is poor. I can install python311 via pyenv, I can activate env, but I have no idea how to run installation of the script (sudo python3 setup.py install) under venv and how to run the goes16-background. I just have no idea how you could start the script with python -m goes16background command. Shall I just install the script under 3.12.5. version and start it with python -m goes16background command?

You either use pyenv to install Python 3.11 or the AUR package. Doesn’t matter, maybe the AUR is simpler to manage.

Then, you have python3.11 on your command line: use it to create a virtualenv:
python3.11 -m venv ~/.venvs/goes16
To install the package, you run:
source activate ~/.venvs/goes16/activate
(your terminal should now show goes16 somewhere in the prompt).
Then, you install the package: pip install -e .

(It may complain about missing packages, you have to install them on your own, because as you already noticed, the original developer is not supporting the package anymore.)

After you installed it, the package installed a runnable file in ~/.venvs/goes16/bin/goes16-background which you can use in the systemd service file.

Nowhere, sudo is needed.

1 Like

Thank you so much! :heart_eyes:
I’m going to follow your advice.

rebuild the package using your current system python

it took me a few minutes

sudo pacman -Syu python-appdirs python-dateutil python-lxml python-pillow base-devel git
git clone https://aur.archlinux.org/goes16-background-git
cd goes16-background-git
makepkg -is

do a test run (described on the github page)

11:58:43 ± [fh@tiger] ~/goes16-background-git
[master ?:3] $ goes16-background
goes16-background 1.2.0
Updating...
Latest version: 2024/09/03 09:30:20 UTC.
Downloading tiles...
Downloading tiles: 1/4 completed...
Downloading tiles: 2/4 completed...
Downloading tiles: 3/4 completed...
Downloading tiles: completed.
Saving to '/home/fh/.cache/goes16background/goes16-20240903T093020.png'...
grep: /proc//environ: No such file or directory
Could NOT retrieve env. var. GNOME_DESKTOP_SESSION_ID
Plasma version 'plasmashell 6.1.4
'.
Result

12:01:59 ± [fh@tiger] ~/goes16-background-git
[master ?:3] $ python --version
Python 3.12.5

The OP might have better success with:

Live-Earth-Wallpapers aka liewa

It looks to be functionally the same as goes16-background, only with satellite selection and more recent project activity.

At face value, this seems a better option than struggling with a long-unattended project.

Wiki links:

Cheers. :vulcan_salute:

1 Like

Does not run or i am doing something wrong (installed with pipx install liewa, python3.12 - the system one)

[teo@teo-lenovo-v15 ~]$ liewa-cli -c /home/teo/test1.yml -o /home/teo
Traceback (most recent call last):
  File "/home/teo/.local/bin/liewa-cli", line 6, in <module>
    main()
  File "/home/teo/.local/share/pipx/venvs/liewa/lib/python3.12/site-packages/liewa/liewa_cli/main.py", line 46, in main
    img = parse_image(args.config)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/teo/.local/share/pipx/venvs/liewa/lib/python3.12/site-packages/liewa/liewa_cli/image_parser.py", line 52, in parse_image
    raw_img = load_geostationary(value,satellite)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/teo/.local/share/pipx/venvs/liewa/lib/python3.12/site-packages/liewa/liewa_cli/full_disks.py", line 66, in load_geostationary
    base_url = build_url(args,satellite,scale)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/teo/.local/share/pipx/venvs/liewa/lib/python3.12/site-packages/liewa/liewa_cli/full_disks.py", line 48, in build_url
    time_code, date = get_time_code(satellite)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/teo/.local/share/pipx/venvs/liewa/lib/python3.12/site-packages/liewa/liewa_cli/full_disks.py", line 24, in get_time_code
    latest = data["timestamps_int"][0]
             ~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Found another similar project, i guess i will try this next

These scripts are a wild rabbit hole to go into. I would recommend just not have a background and use your computer instead of staring at a wallpaper.

Hi again!
I installed python 3.11.2 via pyenv.
It is located in the following folder:
~./pyenv/versions/3.11.2
python3.11 executable file is located in the folder
~./pyenv/versions/3.11.2/bin
to create a virtualenv I open terminal in the folder
~./pyenv/versions/3.11.2/bin (am I right?)
so the command line looks like follows:

~./pyenv/versions/3.11.2/bin python3.11 -m venv ~/.venvs/goes16

the folder .venvs/goes16 is created, BUT it is populated by python 3.12!
Where is my mistake?

Yes, you’re right. But I just want to understand how to create and use python virtual environments now. That’s the task.

If you use pyenv, you should also use pyenv to actually create the virtualenv. Their documentation should be detailed enough.

No need to bang your head against pyenv etc.

Thanks. I did everything and got the following error:
   ~  goes16-background  :heavy_check_mark:
goes16-background 1.2.0
Updating…
Latest version: 2024/09/03 16:30:20 UTC.
Downloading tiles…
Downloading tiles: 1/4 completed…
Downloading tiles: 2/4 completed…
Downloading tiles: 3/4 completed…
Downloading tiles: completed.
Saving to ‘/home/alex/.cache/goes16background/goes16-20240903T163020.png’…
grep: /proc//environ: Нет такого файла или каталога
Could NOT retrieve env. var. GNOME_DESKTOP_SESSION_ID
Plasma version 'plasmashell 6.0.5
'.
Exception in thread goes16-background-main-thread:
Traceback (most recent call last):
File “/usr/lib/python3.12/threading.py”, line 1075, in _bootstrap_inner
self.run()
File “/usr/lib/python3.12/threading.py”, line 1012, in run
self._target(*self._args, **self._kwargs)
File “/usr/lib/python3.12/site-packages/goes16background/main.py”, line 166, in thread_main
if not set_background(output_file):
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/site-packages/goes16background/utils.py”, line 64, in set_background
subprocess.check_output([“qdbus”, “org.kde.plasmashell”, “/PlasmaShell”,
File “/usr/lib/python3.12/subprocess.py”, line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/subprocess.py”, line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.12/subprocess.py”, line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.12/subprocess.py”, line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘qdbus’

qdbus comes from either qt6-tools or qt5-tools. Depending on your DE, I guess the former should be the one to install.

This project actually works, i just tested the latest binary.

You have tagged your topic with Plasma and from the message your are on Plasma 6.0.5

I am on Plasma 6.1.4 - and what I described works

I had to troubleshoot some python dependencies that is all.

qdbus is a core component for Plasma - so there must be something else with your system.

I will do another test using a pristine system installed from Manjaro Plasma 24.0.7 ISO, which - assuming your system is up-to-date - will match yours on the basic level.

//EDIT
This is an example of why custom applications and packages are unsupported on stable branch.

I must emphasize stable branch is largely incompatible with custom packages, of course exceptions exist - printer drivers comes to mind.

In this case the issue is caused by qdbus binary is named qdbus6 - my guess is that Plasma 6.0.x is partly a transission package - a step on the road to a full transission to qt6 toolkit.

With Plasma 6.1.4 - which I use on my production systems - the binary is qdbus as the package expect.

The solution for your usecase is to install the package qt5-tools which provides the qdbus binary for Plasma 5.x - this was already hinted by @mithrial - although it was assumed it should be qt6-tools.

Once again, just to give some more info of the workaround i found. The last site/binary i posted works. All the other python projects did not work. I think at some point the site/path of the images of the website of the Colorado University, which they all parse, changed, so that most scripts break on “file not found”.

So, that said, the biggest challenge was to find good settings for Europe. After that it was easy. A simple script, replacing the image. For now manually, because i am still testing (and next week i will be on metered connection and this pulls 20 meg every time), but it can be made a service, or loop every hour.

/home/teo/Applications/slider-cli -s=meteosat-0deg -c=full-disk -p=geocolor -z=3 -i=1 --crop=914,50,2834,1130 -d=/home/teo/ -f=png &&
sleep 1
rm /home/teo/satellite.png
sleep 1
cd /home/teo
mv $(find -maxdepth 1 -iname "cira-rammb-slider*") satellite.png

And the resulting image, with about 1 to 1,5 hours delay of real time unfortunately:

1 Like

Good to know.

I used Sunclock for a few years, which was a nice indicator of global time (day vs. night), but it wasn’t as dynamic as these projects aim to be.

Ay, ay, sir! I’m moving to the testing branch. If not enough, to the unstable. )