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.
.bashrcis only read by Bash login shells. Your desktop launcher doesn't start a login shell, so you're modifiedPYTHONPATHisn't setwhich python3might help solving your problem. It will show you the path of your current python interpreter. You can also try setting theExecin the.desktopto the path of the venv's python interpreter directly.