Search in PyCharm interactive console command history - python

PyCharm keeps a command history for it's interactive Python console.
Is there a way to access this history with some sort of search instead of just browsing the entries with the arrow keys in the interactive console window?
My environment: PyCharm 2.7 EAP (124.138) on MacOS X 10.8.2.

As of PyCharm 3.1, while in the console, press ⌥⌘e, the "Browse History" window will come up, start typing to search for specific commands

Not available yet, please vote for the related feature requests:
PY-7922 In console, search history by typing prefix and pressing the "up" key
PY-5011 Ctrl+R in console should invoke history search like in bash

Nowadays, there is "Browse Console History" button located to the left of python console. It works on all OS where PyCharm works.
In Windows and Linux there is Ctrl+Alt+E which does exectly the same, but it may not work on Linux if it is overriden by system hotkey Alt.

In Windows you can use Ctrl Alt e

Related

VScode : Everytime I press Run python File in Terminal button, run in powershell always

Everytime I run python file at vscode(in this case I press Run python File in Terminal button), terminal is opened as Powershell always.
my select default profile settings are command prompt. so when I open a new terminal, it opens with cmd. However, when I run the python file even though the cmd terminal is open, a new powershell terminal is launched. and I don't know why...
How do i fix it ?
Yeah, it's an issue of VSCode In version v1.60.0. You can refer to GitHub issue #132150 for more details.
There are a lot of people report this kind of problem recently.
And the only workaround to this problem is to roll back the version to v1.59 until the release of v1.60.1 for now.
There might be an issue in your select default profile settings. However, you can always choose a default shell by pressing ctrl + ~ (~ tilda key) You can open up a shell in vscode, as seen below. By default this might open up powershell, from there you can select your default shell.
Note: Some of the options seen in the image require WSL2 (Windows Subsystem for Linux) to be installed and activated on any Windows system. Clicking any of those options will open a new tab of that shell, but if you click on the '+' plus button or restart vscode later, it will go back to the default shell (powershell) in our case.
Now click the option on the bottom that says select default profile
And you should see a window like this:
From there you can select the default shell in this window. And these changes will be saved, so anytime you click the '+' plus button to open a new shell instance, or relaunch vscode it will open your selected shell choice by default.
And that's it! From here you can select cmd since you want that to be your default shell. And you should be good to go. You can change these settings at anytime, by following these steps again.
Since you're using Python. I suggest using powershell for one reason. You can use a tool known as chocolatey which is like a package manager for windows that can download, install/update, and most importantly set environment variable paths in windows automatically. Which might be a lot easier than doing it manually on cmd.
To run the python script you can do the following:
$ python /path/to/file.py
If you want to run your python file in the terminal with cmd then you just open a new terminal and type the command
python "path/to/file.py"
If it doesn't work try using
py "path/to/file.py"

How to move caret to console in pycharm?

Is it possible to have a keyboard shortcut to move the caret from editor to console and back in pycharm? I can switch the focus between editor and console using CTRL+TAB, but that doesn't allow me to start typing in the console unless I click in it.
I am using the linux community distribution.
I'm on MacOS and PyCharm 2018.2. Doing Ctrl+Tab+P opens up console and focuses on it so I can immediately start typing.
Update: You can also set your own key map: Tool Windows/Python Console. Hitting Esc will focus you back on the editor window.
The key is to hit the TAB key once (potentially twice) after you move into the Python Console (via whatever shortcut you specify in the keymap).
I think it also depends on whether the Python Console is docked - looks like it doesn't work if the Console is in another Window. So my current setup is having the Console docked:
You can use Alt + 4 or Alt + 5 where the digit is the window number. And then to refocus back to the edit you press Enter.
A couple of years later but i found my self in this situations, i believe the other answers are good enough for some but they lack some important information or at least i didn't found it.
You need to look for the term Python or debug console under tools if you want to focus to the console with the caret at it, add a keymap value for that (in my case i added ALT+2), do NOT use the python console under tool windows, for that it will focus on the python console but not the caret at it.
(done with pycharm 2020.1.1 in a ubuntu 20.04 lts machine)

pycharm - keep focus in editor when sending commands to python console

Same question as
Sypder 2 IDE - keep the focus in the editor after sending selected commands to interpreter
but for JetBrains PyCharm. Using option-shift-e on a mac, I can send commands to the python console, but I have to press esc to return focus to the editor. Can I do the Rstudio-style / Emacs-ESS style execution where focus stays in the editor window?
I'm using PyCharm 2.7.3 on Ubuntu 12.04 LTS with Netbeans keymap.
I can use CTRL+ALT+E to execute selected command and for the first time the console has a focus, indeed (first time after lauching IDE). However, any further CTRL+ALT+E leaves the focus on editor. (I can switch back to the console, which is named Run, using ALT+4.)
If newer versions of PyCharm are behaving differently then maybe it's a bug.
Use the built in console and/or built in terminal.

Open python interpreter on intellij

I'm new with python 3.3.
I'm using intellij IDEA 12.1.6.
How can I open the interpreter window, the one with the '>>>' prompt?
Thanks
I am using IntelliJ IDEA 13.1.4 Ultimate with the JetBrains Python Plugin 3.4.135.24.
After installing the plugin and restarting the IDE, I can open the iPython console exactly the same way as in PyCharm, i.e. clicking Tools -> Run Python Console in the menu.
Another option is by selecting some code in a .py file, right clicking and choosing Execute Line/Selection in Console or pressing Alt + Shift + E. If the console has not been opened already, it will open now.
Using the console integrated in the IDE has a few advantages over running iPython alongside it, as listed at in the linked PyCharm documentation page.
Go To Tools -> Python Console
If you want to program python exclusively you may have a look at Intellij's little brother PyCharm. It is specifically designed for python development: http://www.jetbrains.com/pycharm/
Under PyCharm you can open an interactive Python session by selecting Menu->Tools->Run Python Console...
In Intellij (community edition) in terminal (I use Linux, this might differ in your case) I type python3 and it works the same way as in pycharm. With "_" as return value etc. I find this rather useful.

how do I launch IDLE, the development environment for Python, on Mac OS 10.7?

I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.
In the stock Mac OS X python installation, idle is found in /usr/bin, which is not (easily) accessible from Finder and not indexed by Spotlight. The quickest option is to open the Terminal utility and type 'idle' at the prompt. For a more Mac-like way of opening it, you'll have to create a small app or shortcut to launch /usr/bin/idle for you (an exercise left to the reader).
When you open up a new terminal window, just type in
idle
Then you will see a little rocket icon show up as IDLE loads
Then the Python shell opens up for you to edit
I think the shell command is
python -m idlelib.idle
but i am not a mac user so i can't test.
One way to run IDLE from spotlight or an icon in the Applications folder is to build a quick Automation for it. As mentioned by other commentators, this probably isn't necessary for Python 3, as it creates a shortcut automatically, and some hand-installed versions have tools to do this automatically. But if you want to roll your own:
You'll need to know the terminal command to open your version of IDLE. On my Mac right now (early 2016), running python 2.7.10, it is "idle2.7"
Using spotlight, or in the Utilities folder, open "Automator"
Choose an "Application" type document.
Make sure "Actions" is selected in the gray bar, upper left.
In the actions column, find "Run Shell Script" and double-click it, or drag it to the workflow area on the right.
Enter the terminal command in the parameters box that appears.
Save your automation (I called mine "IDLE" and put it in the Applications folder, to make it easy).
It's now available (as soon as spotlight indexes it) via all the normal methods. The only side-effect will be that while it's running, your menu bar will have a spinning gear over in the tray area next to the clock. This indicates an automation workflow is running. Once you close IDLE, it will go away.
first to launch the terminal CMD+space
second to input idle3
the idle will be activated automatically.
After you launch idle from the command line (make sure idle shell window has focus), click File, click "New File". A new window opens; this is your editor.
Type your program in the editor. Click "File", click "Save As...". Save your file somewhere with any name you choose, and a ".py" extension to the file name.
Click "Run", click "Run Module" (or, F5). Assuming no errors, the results will appear in the Shell window. Edit your file & repeat as necessary.
The answer of Matthewm1970 works like a charm!
And if you add an & to your shell command, the automation script will end immediately. There is no spinning gear. Like so:
/usr/local/bin/idle3.5&
Note the ampersand.
Cheers.
-melle
open Terminal
type "idle" and press enter
right click on "Python" icon > Options > Keep in Dock
so for python 3.4.3 in applications a folder named "python 3.4" click that and click IDLE.
for python 2.7.9 go here https://www.python.org/downloads/ and get 2.7.9 and a folder named "python 2.7" click that and click IDLE.
As to the earlier questions about starting IDLE: you can certainly start it from the command line. Also, if you installed Python using Homebrew, you can run 'brew linkapps' (from the command line); that will place an app for IDLE (among other things) in Launchpad (Applications folder).

Categories

Resources