2

I would like to use a Python script to create a video from Stellarium. I have tried several different methods, but so far none have worked. A promising approach is to spawn Stellarium and then use pyautogui to take a screenshot, then kill Stellarium and increment the variable which will change the point of view and run Stellarium with the new command line.

The problem is, I cannot install pyautogui.

Here is the relevant code:

import os import subprocess import pyautogui import time # Set the path to Stellarium and FFmpeg stellarium_path = "/usr/bin/stellarium" # Adjust as necessary ffmpeg_path = "/usr/bin/ffmpeg" # Adjust as necessary # Create a directory to store images output_dir = "/RAID/Server-Main/FlatEarth/Stellarium Screen Shots/Video" os.makedirs(output_dir, exist_ok=True) def capture_images(object_name, field_of_view, start_latitude, end_latitude, longitude, date, dtime): # Loop through the specified latitude range for latitude in range(start_latitude, end_latitude + 1): # Prepare the Stellarium command command = f'"{stellarium_path}" --full-screen=no --longitude={longitude} --latitude={latitude} --fov={field_of_view} --object={object_name} --sky-date={date} --sky-time={dtime}' # Execute the Stellarium command print(f"Capturing image at Latitude: {latitude}") GuiProc = subprocess.popen(command) # Wait for a moment to ensure Stellarium has time to process time.sleep(5) # Take a screenshot screenshot = pyautogui.screenshot() # Save the screenshot screenshot.save(f'"{output_dir}/image_lat{latitude}.png"') # Kill Stellarium GuiProc.terminate 

When I try to load pyautogui I get:

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. 

I tried all the methods recommended by the above error code to no avail. I also tried pip3 install brew so I could possibly use it to install pipx, but I get the same error.

Then I tried

python3 -m venv ~/myenv source ~/myenv/bin/activate pip3 install pyautogui 

and it says:

Requirement already satisfied: pyautogui in /root/my_envs/lib/python3.11/site-packages (0.9.54) Requirement already satisfied: python3-Xlib in /root/my_envs/lib/python3.11/site-packages (from pyautogui) (0.15) Requirement already satisfied: pymsgbox in /root/my_envs/lib/python3.11/site-packages (from pyautogui) (2.0.1) Requirement already satisfied: pytweening>=1.0.4 in /root/my_envs/lib/python3.11/site-packages (from pyautogui) (1.2.0) Requirement already satisfied: pyscreeze>=0.1.21 in /root/my_envs/lib/python3.11/site-packages (from pyautogui) (1.0.1) Requirement already satisfied: pygetwindow>=0.0.5 in /root/my_envs/lib/python3.11/site-packages (from pyautogui) (0.0.9) Requirement already satisfied: mouseinfo in /root/my_envs/lib/python3.11/site-packages (from pyautogui) (0.1.3) Requirement already satisfied: pyrect in /root/my_envs/lib/python3.11/site-packages (from pygetwindow>=0.0.5->pyautogui) (0.2.0) Requirement already satisfied: Pillow>=9.3.0 in /root/my_envs/lib/python3.11/site-packages (from pyscreeze>=0.1.21->pyautogui) (11.3.0) Requirement already satisfied: pyperclip in /root/my_envs/lib/python3.11/site-packages (from mouseinfo->pyautogui) (1.9.0) 

The result /root/my_envs/lib/python3.11/site-packages (0.9.54) is certainly interesting, but it still says:

Traceback (most recent call last): File "/RAID/Server-Main/FlatEarth/Stellarium Screen Shots/./linux_lat_scan.py", line 5, in <module> import pyautogui ModuleNotFoundError: No module named 'pyautogui' 

What should I try next? I'm running Debian Linux Bookworm

0

1 Answer 1

2
--break-system-packages

This can potentially break your system packages. Only use if you understand the risks.

Use it only in your venv.

pip3 install pyautogui --break-system-packages

Or try to use

pipx

pipx install pyautogui

Pipx bypasses the current limitations of Pip by simplifying the installation of Python packages in virtual environments. Pip is a popular tool for installing Python packages and modules from the Python Package Index.


2
  • As I thought I mentioned quite clearly in my original question, attempting to load pipx results in precisely the same issue as attempting to load pyautogui. I definitely do not understand all the ramifications of the situation and I do not understand why in what I think is the virtual environment its says everything is there - I think - but still does not work. Python frequently leaves me shaking my head, and this case is no example. Commented Sep 11 at 2:50
  • That's the problem with Python and all the package versions. It always annoys me too, and the fact that you can't just simply move a venv because of the hardcoded path. Have you checked out all the links? There are various solutions available. Commented Sep 11 at 9:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.