-2

I recently uninstalled Python 64 bit for windows 10 because I wanted 32 bit instead. Before, I could click the script (not edit, just run the script) and the program would just run, the black terminal for python would pop up and display stuff that I printed. I also had another computer recently (I just bought this one) and it worked, it was even a 32 bit python. I could click the script and it would run it. But for some reason it refuses to run. After clicking on the script it says "how do you want to open this .py file?" and gives me a list of apps that has nothing to do with python. I'm on Windows 10 and I have python 32 bit version 3.6.1. It's not a coding error either. If I edit the code and the code is something simple like "print('hi')" it still won't work.

Here is a picture of the programs on my desktop. I have arrows pointing to the programs and I blocked myself out for privacy reasons

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Darth Vador
  • 169
  • 2
  • 4
  • 12

1 Answers1

0

You will need to tell Windows what program handles .py files, it was python 64 bit but you uninstalled it and it looks like 32bit did not set itself to handle them. When you try to run a script you said it asks you what program you want it to be opened by. Attempt to run the script -> click More apps -> Scroll down to Look for another app on this PC if python is not listed in the list of app presented. Before clicking on it, tick Always use app to open .py files and then do. A Open with... window will appear, navigate to your python install directory, by default on Windows this is C:\Users\<user>\AppData\Local\Programs\Python\Python<version>\. In there select python.exe. I think that will work, if not say.

On Linux at least (I don't known about Windows) another way is to use a shebang, see Why do you need to put #!/bin/bash at the beginning of a script file? for more info on this.

Edit: I would rather put this in a comment but i do not have 50 rep so... It look like the files are not associated with python as they did not have a python icon. This is because of your probably/is correct by solution above however it will make it way easier for you and anybody if you had file extensions showing as then you can see and changed them easily from file explorer(/the desktop), see this on how to.

Community
  • 1
  • 1
Max
  • 145
  • 2
  • 15