'PyCharm does not see executables in the PATH

I'm trying to run a browser using the selenium module and the geckodriver executable using PyCharm on a Linux machine. The simplest code to get the error is:

from selenium import webdriver
    
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/') 

I have copied the geckodriver to /usr/bin folder. But I get the following error:

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'

Interestingly, when I copy the run command of PyCharm to a terminal, then everything works fine

/home/doruk/anaconda3/bin/python3 /home/doruk/Kodlar/Python/Boun-Transcript-Crawler/check_selenium.py

In short, the above line works in terminal but gives an error in PyCharm. I have printed the PATH and its length both from PyCharm and terminal.

PyCharm

/home/doruk/anaconda3/bin:/home/doruk/anaconda3/condabin:/app/bin:/usr/bin:/app/extensions/bin:/app/packages/bin:/home/doruk/.var/app/com.jetbrains.PyCharm-Community/data/node/bin:/home/doruk/.var/app/com.jetbrains.PyCharm-Community/data/cargo/bin:/home/doruk/.var/app/com.jetbrains.PyCharm-Community/data/python/bin
316

Terminal

/home/doruk/anaconda3/bin:/home/doruk/anaconda3/condabin:/home/doruk/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
188

I thought it was a PATH issue, but /usr/bin is included in both paths. Any ideas why does not it work on PyCharm?

Edit: It turned out to be a flatpak issue. I uninstalled flatpak version and installed PyCharm from snap. Now, it's working but I still wonder why does this happen in flatpak versions? They does not seem to be able to see some part of the system. (I had similar problems with flatpak versions of UnityHub and Visual Studio Code. All my problems are solved when I replaced them with deb or snap versions)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source