I am just starting to learn Python and I am using Windows 10. I downloaded and installed Python 3.4.3. But everytime I open Python from my Desktop or from C:\Python\python.exe it just opens a black command prompt without any Menu options like File menu, Edit Menu, Format Menu etc. I can't see any colors of the code, it's just black screen with white text. I searched about it on internet and came to know that what I am opening is the Editor winodws and I need to open Shell Window in order to have access to all of those options and features. I can't figure out where is the .exe of Shell Window and with what name is it? Please help me.
P.S. I also tried to open pythonw.exe that was present in the Python folder where it was installed, but nothing opened.
In Windows you will need to right click a .py, and press Edit to edit the file using IDLE. Since the default action of double clicking a .py is executing the file with python on a shell prompt.
To open just IDLE:
Click on that. C:\Python36\Lib\idlelib\idle.bat
Start menu > type IDLE (Python 3.4.3 <bitnum>-bit).
Replace <bitnum> with 32 if 32-bit, otherwise 64.
Example:
IDLE (Python 3.6.2 64-bit)
I agree with one who says:
just type "IDLE" in the start-menu where it says "Type here to search" and press [{ENTER}]
If your using Windows 10 just type in idle where it says: "Type here for search"
My solution to setting options and then invoking Idle on a python script is:
Set optn=blah
...
Set optn=blah
start pythonw C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Lib\idlelib\idle.py STFxlate.py
This allows you to setup the environment prior to invoking idle.
This assumes that pythonw is in the current path
For those using Anaconda, type idle on windows search bar ("Run or Execute command"). This probably wont work if you didn't install anaconda with environment variables. You can also go to
Anaconda3 folder > Scripts >idle.exe
and create a shortcut to you desktop.
Related
I had saved a python file after working on it for sometime, but now when I open it, Python 3.9.1 opens a window then immediately closes. I had done lots of work on this and don't want it to go to waste. I'm on Windows 10.
If you’re using the Open option when you right-click or you are simply double-clicking the script, the program will run and close so fast you won’t even see it.
Here are two options I use:
Open up the Command Prompt. You can easily do this by going to the address bar of your File Explorer and enter ‘cmd’. If you’re in the directory where your script is, the current working directory of the Command Prompt will be set to that. From there, run python my_script.py.
Edit your script with IDLE. If you’re using an IDE, it should be nearly the same process, but I don’t use one so I wouldn’t know. From the editor, there should be a method for running the program. In IDLE, you can just using Ctrl + F5.
Right click on it and clicken "open with". Then choose Python IDLE.
You are trying to run the file instead of editing it.
You have to right-click the file and you should the "edit with idle" option.
Is there a way to differentiate between a .py file launched by double-clicking its icon in Windows versus typing myscript.py in an existing command prompt window? My code ends with os.system("pause") so that I can see the results when double-clicking to launch, but that line should be ignored when running it in a persistent window.
I would first recommend you to go to advanced settings of your Windows Explorer and activate the "show extensions" options if that can help.
For more information about your question, you can also check this link :
https://automatetheboringstuff.com/appendixb/
I'm on Linux Mint running VSCode and I was somehow able to run a terminal not as a separate window but right below an open Python file. Seems to be easy on Win/OSX (Ctrl/Cmd+J and select Terminal tab) but not specifically a feature that I can choose when I'm on a Linux machine. Any special keys to bring it back?
In general, Ctrl-` opens the integrated terminal in VS Code. Otherwise look under the View menu for the Integrated Terminal option. If you're looking for Python-specific options, there are Run Python File in Terminal and Run Python Selection/Line in Terminal commands from the command palette.
I am a beginner of spyder IDE for Python.
To use spyder IDE, I command "spyder" on anaconda console with python 2.7
After that, I try to print "hi"
But I encounter an error message
"No python shell is currently selected to run hu.py Please select or open a new Python interpreter and try again"
How could I solve this problem?
I saved my file on C:\Anaconda\practice_jhk
from __future__ import print_function
print ("hi")
You can specify the Spyder's Run Settings in Run -> Configure (F6). By default "Execute in current Python or IPython console" is selected and you probably do not have any open console in Spyder.
You can select "Execute in a new dedicated Python console" option and Spyder will automatically open a new console for you. Or you can leave the dafault option and create a new console yourself in the Consoles menu.
I have had the same problem. I am not able to fix it but I am able to successfully run the program the following two ways and I don't find any problems till now:
By selecting IPython console (not the one with the Kernel id as its tab) then running your program.
By selecting "Execute in new dedicated Python console" from Tools --> Preferences --> Run.
I was getting the same error message, but then realized I was not directing the PATH to my Python interpreter file at all. How I solved the problem:
Go to Tools > PYTHONPATH manager
Select "Add path"
Find and select your Python interpreter folder (for me this was C:\Python27)
Try, tools -> Reset sypder to factory default. Then, click on the run button in the dialog box.
I had this issue when I didn't have the python console pane open.
To resolve this, in the top bar go to: view -> panes and turn ipython console on.
This fixed it for me.
You might have unexpectedly closed the Ipython console window which is open by default and that caused the error.
Go to Consoles > New console(default settings)
I'm trying to teach Komodo to fire up IDLE when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving this path to Komodo causes it to say that 1 is returned. This appears to be a failure as IDLE doesn't start up.
I thought I'd avoid the shortcut and just use the exact path. I go to the start menu, find the shortcut for IDLE, right click to look at the properties. The target is grayed out, but says "Python 2.5.2". The "Start in" is set to, "C:\Python25\". The "Open File Location" button is also grayed out.
How do I find out where this shortcut is really pointing? I have tried starting python.exe and pythonw.exe both in C:\Python25, but neither starts up IDLE.
There's a file called idle.py in your Python installation directory in Lib\idlelib\idle.py.
If you run that file with Python, then IDLE should start.
c:\Python25\pythonw.exe c:\Python25\Lib\idlelib\idle.py
In Python 3.2.2, I found \Python32\Lib\idlelib\idle.bat which was useful because it would let me open python files supplied as args in IDLE.
Here's another path you can use. I'm not sure if this is part of the standard distribution or if the file is automatically created on first use of the IDLE.
C:\Python25\Lib\idlelib\idle.pyw
If you just have a Python shell running, type:
import idlelib.PyShell
idlelib.PyShell.main()
there is a .bat script to start it (python 2.7).
c:\Python27\Lib\idlelib\idle.bat
Python installation folder > Lib > idlelib > idle.pyw
Double click on it and you're good to go.
You can also assign hotkeys to Windows shortcuts directly (at least in Windows 95 you could, I haven't checked again since then, but I think the option should be still there ^_^).
The idle shortcut is an "Advertised Shortcut" which breaks certain features like the "find target" button. Google for more info.
You can view the link with a hex editor or download LNK Parser to see where it points to.
In my case it runs:
..\..\..\..\..\Python27\pythonw.exe "C:\Python27\Lib\idlelib\idle.pyw"
I setup a short cut (using windows) and set the target to
C:\Python36\pythonw.exe c:/python36/Lib/idlelib/idle.py
works great
Also found this works
with open('FILE.py') as f:
exec(f.read())
Another option for Windows that will automatically use the most recent version of Python installed, and also doesn't make you look for the installation path:
Target: pyw -m idlelib
Start in: Wherever you want
I got a shortcut for Idle (Python GUI).
Click on Window icon at the bottom left or use Window Key (only Python 2), you will see Idle (Python GUI) icon
Right click on the icon then more
Open File Location
A new window will appears, and you will see the shortcut of Idle (Python GUI)
Right click, hold down and pull out to desktop to create a shortcut of Python GUI on desktop.
Python installation folder > Lib > idlelib > idle.pyw
send a shortcut to desktop.
From the desktop shortcut you can add it to taskbar too for quickaccess.
Hope this helps.
If it's installed on windows 10 without changing default location, it seem it is in "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0x64__{BUNCHOFRANDOMSTRINGS}"
and you won't be able to open it.
Good luck finding how open .py by default with idle.