0

I have written a python script using Python 3.10 and like to start the script via my PoP OS! library link that I created. My .desktop file is in the correct directory in usr/share/applications, was installed by xdg-desktop-menu install .desktop and looks as follows:

[Desktop Entry]
Version=1.0
Name=Ausgaben-App
Comment=...
Exec=python3 "/home/pz/PycharmProjects/pythonProject4/db-expenses.py" 
Icon=/home/pz/PycharmProjects/pythonProject4/Ausgaben-App.ico
Terminal=true
StartupWMClass=Ausgaben-App
Type=Application
Categories=Application

I made my pythonscript executable by means of chmod +x . I am able to start my python script from the terminal. When I copy the line of the desktop config file behind the Exec in the terminal my script starts without any problems. But when I click the app icon in my PoP OS! library a terminal windows opens for 1/10 s and shows the import error "No module named pandas", afterwards nothing happens.

I defined my pythonpath in the .bashrc file as follows:

export PYTHONPATH=/home/pz/PycharmProjects/pythonProject4/venv/lib/python3.10/site-packages:/home/pz/PycharmProjects/pythonProject4/venv/bin:/home/pz/PycharmProjects/pythonProject4

I am not very accustomed to use and set up python-scripts / python IDEs in combination with a linux OS. I don't check why I can run my script from the terminal, but with the same execution path inside a .desktop file the app don't starts. I already looked up various other threads regarding this or similar problems but I am not able to solve this problem on my own. Any help / advice would be welcome.

I guess that the definition of my python path is not set correctly, but I wonder why the script starts via terminal?! I reinstalled my library link with xdg-desktop-menu uninstall / install, I removed it entirely, made it executable again and installed the desktop link again. Without any success.

Axiom42
  • 35
  • 4
  • Related / potential duplicate: [What's the difference between .bashrc, .bash_profile, and .environment](https://stackoverflow.com/q/415403/11082165). `.bashrc` is only read by Bash login shells. Your desktop launcher doesn't start a login shell, so you're modified `PYTHONPATH` isn't set – Brian61354270 Jul 28 '23 at 19:31
  • Please note that normally questions about configuring launchers / customizing your desktop environment are off-topic on Stack Overflow. You may be able to ask on Unix & Linux SE or Super User. – Brian61354270 Jul 28 '23 at 19:33
  • 1
    Running `which python3` might help solving your problem. It will show you the path of your current python interpreter. You can also try setting the `Exec` in the `.desktop` to the path of the venv's python interpreter directly. – VANN Universal Jul 28 '23 at 21:10
  • Thanks for your comments, they solved my problem. – Axiom42 Jul 29 '23 at 08:00

0 Answers0