Just installed Python 2.7.3 on a Windows7 machine.
How do I get .py files to be associated with python (they are with notepad ATM) and how do I get the context menu shortcut for "edit in IDLE"? Somehow I didn't get that on this particular computer.
try making a .py file and then try to open it, and a window should appear asking you what to open it with, and then select idle in your program files.
Related
I just uninstalled and reinstalled python on my Windows machine. Before I uninstalled my previous version I was able to just double-click on a python script and it would open the command prompt, run the script, and close automatically. After re-installing with the newest version (3.9), I am no longer able to execute the script like that with a double-click.
Clearly I had done something special last time to set that up for myself, but I don't remember what it was. Any idea how I can get that double-click deal going again?
Doing the following should fix it:
Right click on the .py file you want to open;
Open with -> Choose default program -> More options;
Select the python.exe file.
Explanation:
Your Python scripts have to be processed by another program called the Python interpreter. The interpreter reads your script, compiles it into bytecodes, and then executes the bytecodes to run your program.
Installing a new version might have messed the path to the Python interpreter. The steps listed above will tell Windows to associate .py files with your Python interpreter, thus fixing the issue.
This link with Python on Windows FAQ might also be of help.
There will be an option of "Open With" after right-click on the file go and choose CMD. I hope it helps if not then sorry. Because I use Parrot OS
Save the following text to a file called something like python.reg (the .reg extension is important). You might need to modify the last line to be your exact path to python.exe!
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.File\shell\open]
[HKEY_CLASSES_ROOT\Python.File\shell\open\command]
#="\"C:\\Python2.7\\python.exe\" \"%1\" %*"
Find the python.reg file you just saved and double-click it to load those contents into your Registry. If you've performed one of the other operations in other answers (like "Open With"), those "UserChoice" settings are stored somewhere else in the Registry and will override the "Classes" setting shown in this script. So, do one or the other, don't combine them!
I am trying to open my python files with a double click. I normally open them in anaconda prompt which uses the powershell file found in C:\Windows\System32\WindowsPowerShell\v1.0. I tried using open with and navigating to this file, however then the promt window opens and immediately closes... the script should run continuously.
I also tried opening it with the "python (command line)" file which I found in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 2.7 I cannot open the location of that file for some reason using right click> open file location, however I tried to open my script using this but again the same thing happens.
It is frustrating as I need to close and open my scripts often. Each time I have to load up anaconda prompt, type in python and drag the file, and than press enter.
Any help would be appreciated.
I have installed Python 3.7 btw that I installed with ana and am trying to avoid reinstalling python as I have so many npm installs done that I did not keep a log of.
Try to open file/folder in other IDE like vscode, pyCharm or text editor.
Open IDE first after that click on file menu and select open option.Browse the file/folder and select it.
So I had python for a long time, but I didn't code just downloaded scritps and all that. I wanted to install python 3.7, when I did everything seemed to work fine, but my .py files didn't open.enter image description here
Images
You may tell windows what program should open py files with. If you want to open them with a text editor or a python interpreter installed, etc. Go to start menu and type "default programs", from there you need to tell windows what praogram you want to associate with py file
I have installed Anaconda, but I do not know how to open a .py file..
If it is possible, please explain plainly, I browsed several threads, but I understood none of them..
Thanks a lot for your helps..
Best,
In the menu structure of your operating system, you should see a folder for Anaconda. In that folder is an icon for Spyder. Click that icon.
After a while (Spyder loads slowly) you will see the Spyder integrated environment. You can choose File then Open from the menu, or just click the Open icon that looks like an open folder. In the resulting Open dialog box, navigate to the relevant folder and open the relevant .py file. The Open dialog box will see .py, .pyw, and .ipy files by default, but clicking the relevant list box will enable you to see and load many other kinds of files. Opening that file will load the contents into the editor section of Spyder. You can view or edit the file there, or use other parts of Spyder to run, debug, and do other things with the file.
As of now, there is no in-built way to load a .py file in Spyder directly from the operating system. You can set that up in Windows by double-clicking a .py file, then choosing the spyder.exe file, and telling Windows to always use that application to load the file. The Anaconda developers have said that a soon-to-come version of Anaconda will modify the operating system so that .py and other files will load in Spyder with a double-click. But what I said above works for Windows.
This answer was a bit condensed, since I do not know your level of understanding. Ask if you need more details.
You can use any text editor to open a .py file, e.g. TextMate, TextWrangler, TextEdit, PyCharm, AquaMacs, etc.
I just upgraded to windows 10, and downloaded the Anaconda Python distribution and chose the option for it to add everything to my PATH etc. Back in windows 8 when I created a .py file I could execute it from the file explorer just by clicking on it, but for some reason windows 10 won't recognise .py files and when I try run them it opens them in notepad. I am able to run them from the command line. What's gone wrong?
UPDATE: When I choose another application to open the file, I click on the python application and it says "Cannot Execute as Python27.dll is not found", I installed python 3, why is it trying to open in python2.7?
Choose open with, then scroll down and click something like "choose another application from this computer" (I don't exactly know, I use windows in different language). Then just select your Python executable and click OK.