Registered Member
|
Hi,
I want to open simple .py files with a simple text editor like gedit. However, every time I try to open it, it launches Okular, because it thinks it is a PDF Document. As you can see in the screenshot, the filename pattern .py corresponds to python text files and and .pdf pattern is set for PDF-files. But in the file explorer it still says download.py is a PDF Document. Why does this happen? And how can I permanently fix that (so that I dont have to ask again in the future, if this happens more often)?
Screenshot: https://ibb.co/12MxTnb Best regards |
Manager
|
In System Settings -> Personalization -> Applications -> File Associations, remove Okular from the Application Preference Order for the x-python and x-python3 file types, it shouldn't be in there anyway, there should only be text editors.
Also make sure the header of your script is formatted correctly, ideally all Python scripts should start with this:
Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ... |
Registered Member
|
Hi Mamarok,
thanks for the answer. The problem is, that Okular isn't even set as Application for python files. The only applications that are set are "Text Editor" and "VS Code" (as seen in the bottom left window of the screenshot; the file association for x-python3 is the same). That's why I am supprised as well The header of the script is the following (set to my installation path of python):
BTW: I am using the newest Manjaro distribution with KDE and the Kernel 5.8.18-1-MANJARO and the DE Plasma 5.20.2 (if this is of interest). |
Manager
|
That is weird, I tried creating a test script, it is correctly shown as being a python script in the properties. Is this over all or is it just this one script?
Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ... |
Registered Member
|
So after some debugging I found out that in the script one line was
After trying to isolate the error, I found out that if in any file the string %PDF-1.5 exists, it tries to open the file with Okular, no matter the file extension. If I remove this, it opens the file with the plain text editor, as expected. I suspect this to be a bug of some kind, isn't it? I understand, that if a file starts with this string, it probably is a pdf file, but 1. I would assume/hope, that KDE only uses the file extensions to figure out how to open it (that way it is way more intuitive) and 2. it doesn't even start with the string. The string is somewhere in the file. Some more (maybe interesting) information: If I call "file download.py", it says download.py: Python script, ASCII text executable, while when I do that for a test script, which is also opened with Okular, it says test.py: PDF document, version 1.5, ASCII text (test script:
Maybe you can try it on your machine as well, to see if it is reproducible on other systems. |
Manager
|
I just tried and it is indeed reproducible here as well. You should report this as a bug against Dolphin
Running Kubuntu 22.10 with Plasma 5.26.3, Frameworks 5.100.0, Qt 5.15.6, kernel 5.19.0-23 on Ryzen 5 4600H, AMD Renoir, X11
FWIW: it's always useful to state the exact Plasma version (+ distribution) when asking questions, makes it easier to help ... |
Registered users: bancha, Bing [Bot], daret, Evergrowing, Google [Bot], lockheed, mesutakcan, sandyvee, Sogou [Bot]