3

As the title states, I'm trying to use Windows python on linux,
which already has worked flawlessly for what I've needed to run.

however .py files open with gedit instead of python, meaning I actually have to open python directly before I can do anything.

I've read an example that told me about a desktop entry for pdf files, but of course I don't know what I'm doing and nothing's explained for noobs, so I tried rewriting it to work with python:

[Desktop Entry]
Name=Python
Exec=wine python.exe %F
Icon=python
Type=Application
Categories=Viewer StartupNotify=false
Terminal=true
MimeType=application/py

the terminal just appears then disappears

what am I doing wrong??

  • Can I ask why ? – philshem Oct 7 '14 at 20:17
  • I'm trying to run a portable windows interpreter across Linux and mac – Tcll Oct 7 '14 at 20:19
  • Is it a terminal application? I guess the Categories=Viewer StartupNotify=false is a typo? – Jacob Vlijm Oct 7 '14 at 20:21
  • no, I just have the terminal up because I like to know it's working. (can always disable it when it works) – Tcll Oct 7 '14 at 20:57
  • Hmm, that does sound like a pretty strange association to want, but I guess it won't really interfere with *nix-native python scripts, which all use #! anyway ... – SamB Feb 2 '15 at 18:07
4

managed to get it working:

for noobs, open your terminal and input:

gedit ~/.local/share/applications/OpenWithPython.desktop

once open, copy and paste this in the file and save:

[Desktop Entry]
Name=Python
Exec=wine C:/python27/python.exe %F
Icon=python
Type=Application
Categories=Viewer
StartupNotify=false
Terminal=true
MimeType=application/py

now just R-click > Open With Other Application > Show Other Applications > Python


for pyw files:

gedit ~/.local/share/applications/OpenWithPythonw.desktop


[Desktop Entry]
Name="Python - no console"
Exec=wine C:/python27/pythonw.exe %F
Icon=python
Type=Application
Categories=Viewer
StartupNotify=false
Terminal=false
MimeType=application/py

^ it really doesn't matter if you use python.exe or pythonw.exe here


I've also gotten IDLE working properly:

gedit ~/.local/share/applications/EditWithIDLE.desktop


[Desktop Entry]
Name=IDLE
Exec=wine C:/python27/python.exe C:/Python27/Lib/idlelib/idle.pyw %F
Icon=python
Type=Application
Categories=Viewer
StartupNotify=false
Terminal=false
MimeType=application/py

^ just associate it with the "Open With" menu


also, if you use a different python version, you can always change the python27 directory to python34 or whatever version you use.

| improve this answer | |
  • Indeed, Python for Windows doesn't normally add itself to the %PATH%. – SamB Feb 2 '15 at 18:08

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.