2

I am trying to run on a remote Linux cluster a PyQGIS python script I wrote, after managing to run my script locally, but I am having trouble setting up things in the Linux server.

To run the script locally, I followed the steps indicated in https://stackoverflow.com/questions/35622661/import-qgis-modules-into-python-anaconda/67447061#67447061 which comprise running

import sys
sys.path

on the Python console of QGIS GUI. However, I cannot open the QGIS GUI in the Linux cluster. T

Is there any way I could open the QGIS Python console directly from the Linux command prompt?

I already installed QGIS in a conda environment on the Linux cluster (it is QGIS version 3.18.3).

1 Answer 1

3

This may help. See this link for running QGIS processing scripts from a command line without having to open a QGIS GUI.

Here I place a script called start.py in my home directory in Ubuntu. The contents of start.py are

print('QGIS Python ran this')

Then, from a terminal I type:

$qgis_process run start.py

This returns QGIS Python ran this in the terminal. It also returned text stating that start.py is not a valid Processing script but I suspect you will not get that message if your script is valid.

2
  • qgis_process run start.py did not work with message: qt.qpa.xcb: could not connect to display localhost:10.0 qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. After some research I ran export QT_QPA_PLATFORM=offscreen. And then qgis_process throws error: Problem with SAGA installation: SAGA was not found or is not correctly installed Algorithm start.py not found! Any advice? I don't have admin rights to cluster
    – CSG_10
    Mar 20, 2023 at 17:11
  • No, other that search GIS SE for help on settings to get SAGA working. That was straight forward on a Linux laptop but I don't know about the server...Or ignore the return if you don't need SAGA. Best to start a new question on the topic. Conversations in the comments are frowned upon by the administrators.
    – GBG
    Mar 20, 2023 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.