Visual Studio Code; how to open two Python shells side-by-side - python

I can open a terminal with command "Python: Create Terminal" and that works great. It is using my selected Python Interpreter that I created with pipenv. But I want to create two of these terminals side-by-side.
If I split the terminal, a new bash terminal starts that only knows about the system installed Python.
If I create another Python terminal, it opens by itself. The two terminals are running but I can only display one or the other
Is there a way to have two Python terminals open and displayed at the same time?
I'm on windows10.

Not from the Create Terminal command, no. But you can copy and paste the shell command that gets executed by Create Terminal in the second shell and it will lead to the same result.
We also have an open feature request that would solve this by automatically executing the appropriate command on every opened terminal. Feel free to leave a :+1: reaction to the issue to let us know you would like to see the feature implemented.

Related

VS Code : Run python File in other terminal

In VS Code, when I launch a python process, the terminal is busy running it.
If I then want to run a new python process (By running "Run python File in Terminal") then it just queues it up in the same terminal.
I am happy to manually create a new terminal, and put it in focus, but when I select "Run python File in Terminal" then VS Code automatically switches to the old one, and so does not run the code.
How can I solve that?
(Note that I saw this question, but it is not the same because I do not want to automatically spawn a new terminal - the new terminal is already there)

Is there a way I can remove all Windows's restore points with Python?

Every time when I'm uninstalling a software (Revo Uninstaller Pro), a new Windows restore point is created, and I want to create a simple script that I will put on my Desktop, that every time I click on it, my Windows's restore points will be deleted, But I don't want to fully disable it because this is important.
I have asked Google, but I didn't find anything about it with Python.
Is there a way I can delete all Windows's restore points ?
You cannot do this directly with python. You need to run a power shell script that does this and invoke it from python.
Microsoft already wrote the power shell script for you: https://gallery.technet.microsoft.com/scriptcenter/Script-to-delete-System-4960775a
How to invoke a power shell script from python Running powershell script within python script, how to make python print the powershell output while it is running

PyCharm running Python file always opens a new console

I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality.
I'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations.
I would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?
There is a specific option in PyCharm 2018.2+: Settings | Build, Execution, Deployment | Console | Use existing console for "Run with Python console".
Run with Python console is an option you have enabled in the Run Configuration. Disable it if you don't need a Python console after a script execution:
Hi: If you are looking for re running the code again in the same python console everytime then you have to check the respective box in the Project settings as shown in image below.
To allow only one instance to run, go to "Run" in the top bar, then "Edit Configurations...". Finally, check "Single instance only" at the right side. This will run only one instance and restart every time you run.
One console is one instance of Python being run on your system. If you want to run different variations of code within the same Python kernel, you can highlight the code you want to run and then choose the run option (Alt+Shift+F10 default).
You have an option to Rerun the program.
Simply open and navigate to currently running app with:
Alt+4 (Windows)
⌘+4 (Mac)
And then rerun it with:
Ctrl+R (Windows)
⌘+R (Mac)
Another option:
Show actions popup:
Ctrl+Shift+A (Windows)
⇧+⌘+A (Mac)
And type Rerun ..., IDE then hint you with desired action, and call it.
I think that what you are looking for is the last option in this window; check it and it should work.
Settings -> Build, Execution, Deployment -> Console

Run terminal inside VS Code for python script?

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.

How to run same application in new run tool window? Pycharm Community 2017

I am working on a Python 3.6 project in Pycharm Community Edition 2017.2.3.
I have multiple run configurations in my project. Each different run configuration will open a different 'Run tool window'.
I want to look through the output of the previous run of my application while re-running it in another tool window. However, each new run of the same configuration will overwrite the console output of the previous run. How do I run the same application/configuration in a new tool window?
It's probably possible to just duplicate the configuration, but I'm looking for a better way. Maybe something similar to opening new terminals?
Go to build configurations and enable show command line afterwards.
It simply opens the python interpreter in the console after running your code.
Now When you run the code again. It will open a new tab in the run window, instead of overwriting the old one.
You can pin first tab by right click then run another script
I do not think if it is possible. But you can do it using terminal.
It's still in Run/Debug configurations but now it's called, "Run with Python console".

Categories