Double-clicking Python File Launch

I have a really nasty problem, I can't run a Python file just by double-clicking.

I tried installing it to open the file using idle.bat , but it only runs the IDLE editor with a double click, it does not run the Python file.

+8
source share
5 answers

What version of Python did you install?

You must write your own batch file to execute your python binary and script.

For example, if you installed Python 2.7 by default on Windows, it could be the entire contents of your script.

myscript.bat :

 ECHO ON REM A batch script to execute a Python script SET PATH=%PATH%;C:\Python27 python yourscript.py PAUSE 

Save this file as "myscript.bat" (make sure it is not "myscript.bat.txt"), then double-click it.

+11
source

Right-click the file, select it. If you want to just run the script, find python.exe and select it. If you want to debug using IDLE, find this executable and select it.

+2
source

right-click on file-> open with-> select by default program-> more options-> select the python.exe file and click.

+1
source

When I had both Py2 and Py3, and then I deleted the first one, my script did not start if I double-click it (but normally from the console). I realized that my __pycache__ folder (the same directory as the script) was the problem. The problem is resolved upon removal.

0
source

"sounds like python is not in your PATH" - Nick A 2 hours ago

When reinstalling, I clicked on installing Python in Path and worked to solve this problem.

-2
source

Source: https://habr.com/ru/post/1262759/


All Articles