I would like to run a pyhton script with conflicts with the use of a certain graphical framework:

ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running

Therefore I would like to ask if there is a way to determine all processes that currently 'qt5' and depending on the result kill them so that I can run my script. (The script worked all the time before just fine - no idea by which application this was caused)

  • You can use lsof to find processes that use a certain file. If you know which files are involved in "using qt5" than you can check these. – Lucas Oct 21 '20 at 20:11
  • @Lucas is there a way to do it when I only have the information from the error message to determine why/for which applications qt5 is running and how to stop qt5? (There seems to be no process called qt5 or similar - at least htop doesn't provide any results to me) – baxbear Oct 21 '20 at 21:09
  • You ask your package manager about all installed packages that have anything to do with qt5. Then ask the package manager about all installed packages that use these (recursively). Then list all files of all these packages. (Maybe only executable files?) Check against that list. – Lucas Oct 21 '20 at 22:14

This finds the first 5 pids on my machine using libnss_files-2.23.so.

$ for p in /proc/[0-9]*
    do test -d $p/map_files && 
    sudo ls -l $p/map_files | 
        awk -vpid=$(basename  $p) -vname=libnss_files-2.23.so -F '->' \
            '$2 ~ name {print pid; exit}'
  done |
  head -5 

These days on Linux, find all pids with property X is frequently solved with procfs.

  • Does libnss_files have anything to do with qt5? Or is there some file that will probably be used by a process using qt5? – Lucas Oct 21 '20 at 22:15
  • 1
    The library I chose was arbitrary; I don't use Qt. ISTM likely that all programs running under Qt will be linked to some runtime support library. If the OP finds one likely candidate, the above script can serve as a basis for searching the process tree in the way he wants. – James K. Lowden Oct 22 '20 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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