PyCharm Run Tool Window (Run Tab Window) is missing - python

So recently my PyCharm is missing its run tool window that usually show the run/debug results. it is now replaced with python console and services, which is really frustrating because It's just showing gibberish and command-prompt-like format.
How do I return the run tool window back as my main run/debug window?
I have circled the tabs/windows that I meant in this pic with red circle.
Note: usually I can access this run tool window by pressing alt + 4.
Please see red circle:
This is my run config:
This is my view tab bar, it doesn't show run (alt+4):

right-click on the code.
More Run/Debug
click on modify run configuration
un-select run with python console

From what I understand you want the run icon pinned to your lower toolbar. (This corresponds to running whatever your last chosen configuration was.)
Two easy steps:
1º View -> Tool Windows -> Run
2º Right-click run icon on lower tool bar -> View Mode -> Dock Pinned
Edit after OP feedback:
If your Run (Alt+4) option has disappeared completely, besides trying a PyCharm reinstall it's advisable to manually clean the preference files that might be hidden. Check the following paths C:\Users\user_name\AppData\Local\JetBrains and C:\Users\user_name\AppData\Roaming\JetBrains, C:\Users\user_name\.PyCharmCE2020.x, and C:\Path_to_your_Project\.idea. Some of there directories might be hidden so you'll have to check you've set them to be visible.
Even by reinstalling PyCharm some of the above configurations are likely to be kept. There's a strong possibility the state of whatever changes that caused Run to disappear is kept in files inside the above mentioned directories.

Related

Run button isn't working in Pycharm. How do I fix this?

In PyCharm the run button is in grey, not allowing me to click it to run my code. Is there a simple fix to this?
It is happening because your interpreter isn't configured for your current file. You can run your file easily by right clicking on the tab in which your file is open, and then selecting "run (name of file)". It will automatically configure that file, so you can use the run button after that to run it. Remember that you'll have to do this for every new file that you open.
In order to run things, you should configure few things:
you must select which is the root directory of your code: some people uses directly the root directory (but for test, docs, and eventually also utils (and likes), so also in this case you must select all roots), some people put code in a directory named src or as the package name. In this case you should select it (left click on project panel [the panels with the file and folder list], Mark directory as... menu item).
you should have a default python environment for the project (or some available environments). Go to Settings, Project: ..., Project environment
Then you should configure the run option. Usually it is on left from run button. Click it, and add a run setting: at minimum you should select which file should be run (and the environment, if you didn't yet have a default environment for your project). Later you can configure more suffs, as you like.
There are also other possible reasons, e.g. wrong extension, really bad formatted file, etc., which could hit new programmers. But in such case, we must have more information. Try with a very simple example, e.g. just one line: print("Hello World"), to know that the above 3 steps are correct.

Configuring sublimeREPL to build to new window or same tab

I am just now getting started with Sublime Text 3 and SublimeREPL for Python usage and I am beginning to enjoy it. I am trying to configure my space to be as efficient for me as possible. So far I have configured my SublimeREPL to reuse the tab when running code, namely:
Adding:
"view_id": "*REPL* [python]",
in the "repl_python_run" command in SublimeREPL\config\Python\Main.sublime-menu,
and then to changing:
if view.name() == view_id:
found = view
window.focus_view(found) # <-- add this line
break
in SublimeREPL\sublimerepl.py.
As a result, I am able to reuse the same tab after a build. I am looking for two possible enhancements to my space:
1) If i disattach the tab that runs python in interactive code and build again, it creates a new tab. How can I have it so that when I build, interactive mode launches in a new window and I can reuse that window everytime I build?
2) How can I have the bottom of my Sublime Text have an interactive output, similar to RStudio? This way I can see the results of each build in the same window, and make modifications as necessary without switching tabs/opening new windows.
Any help would be appreciated!

Prevent PyCharm from opening the browser/new tab on run

I found a number of people who want PyCharm to open the browser/a new tab every time you click run.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206590705-How-do-I-setup-Run-Debug-Config-to-open-browser-automatically-for-Flask-
Django manage.py runserver doesn't open browser
Well, I click run often and already have the tabs open I need. It's quite frustrating to have to close the new ones, and I want to turn it off. I have looked thru all the menus and I can't find the Run browser setting some people talk about.
I also tried disabling all Django support for browsers in Settings -> Tools -> Browsers, but this made no difference.
Versions:
PyCharm 2017.1.1
Python 3.5.x
Django 1.10
edit run configurations(right next to the play button at the top of the editor) and uncheck the box that says open new window on run .... – #Joran Beasley
P/s: Just comment again.
For version 2018.3
Go to File | Settings | Build, Execution, Deployment | Console.
Check the option Use existing console for "Run with Python console".
2018 :
Edit run configurations (at the left to the play button at the top of the editor, click on the list of configuration then edit configurations) and check the box that reads single instance only

How do I run doctests with PyCharm?

In the PyCharm IDE, if I right-click on a function/method with a doctest, sometimes the right-click menu will give me the option: "Run 'Doctest my_function_name'" and sometimes the right-click menu, instead, only gives the option to run the whole file (NOT as a doctest).
What determines when it will give the "run doctest" option and when it will not? Is there a way to force it one way or the other?
Running a module (or the tests in it) in PyCharm is done via a Run Configuration. When you right click a module, PyCharm searches for an existing Run Configuration for that module. If a configuration is found (this can be due to a previous run, or a manual creation of a Configuration), PyCharm will only suggest to run that configuration.
For example, if a configuration of module.py was created to run its doctests, that is the option we'll see when right-clicking module.py. However, if no configuration is found, PyCharm suggests to run the module in different options, depending on the code in the module (run regularly, or run doctests / unittests). Once an option is chosen, PyCharm creates the respective, temporary, Run Configuration, implicitly. From here on, when right clicking the module, you'll only get the configuration that was created for that module.
Important side note: PyCharm saves up to 6 temporary (i.e., Configurations that were created via running a module) Run Configurations- 3 in "Python", i.e., scripts, and 3 in "Python Tests". This means that if you run moduleA.py, moduleB.py, moduleC.py, and then moduleD.py, the temporary Configurations in PyCharm will be moduleB.py, moduleC.py, and moduleD.py. The configuration of moduleA.py will be automatically deleted, unless explicitly saved.
This behaviour can be reproduced as following:
In PyCharm, create a new Python module: "temp"
2.Add the following to the module:
"""
>>> print 3.14
3.14
"""
if __name__ == '__main__':
pass
Right click on the doctest section gives the option to "Run 'Doctests in temp' "
Right click on the main section gives the option to "Run 'temp' "
Choosing anyone of the options, makes the other option disappear in subsequent runs. E.g., choosing to run the module will make the option to run Doctests disappear in subsequent runs, and vice versa.
Going back to the first stage, where it was possible to choose between the two options, is possible by deleting the module's "Run configuration":
Run --> Edit configuration --> Locate the module's current configuration (usually highlighted) --> Click the "Minus" button (top left corner) --> Click "Apply" --> Click OK.
Now we are back at step 3.
(Reproduced in PyCharm 5.0 and 4.5)
To summarize:
If no Run Configuration is found, PyCharm suggests to run the module in any possible way (as a script, doctests, or unittests)
If a Run Configuration is found, PyCharm only suggests that Configuration.
If PyCharm isn't giving you the run option that you want, find the Run Configuration that is preventing it from giving you that option and delete it, or create a new one that will run the file, or method/function, the way you want.
If you don't want to delete configurations, you can also hit the shortcut key for Run | Resume Program (F9 for me) to pop up a complete list of choices
If the above doesn't work for you - make sure that your module is not named doctest; it will cause a conflict and therefore cause the exception.

Running code in PyCharm's console

Are there any smooth way to run Python scripts in the PyCharm's console?
My previous IDE - PyScripter - provides me with that nice little feature. As far as I know PyCharm has 2 ways of running script in console:
1) Select a bunch of code and press Ctrl+Alt+E.
2) Save the code in a file and import it from the Console.
Are the any way to do it by pressing "Run" or "Debug" buttons? I need to see the result of my script in the console and all variables available to manipulate.
In the Run/Debug Configuration, add -i to the interpreter options. This will stop it from closing a python session even after a successful run. I.e. you will be able to see all the variable contents
Run -> Edit configuration -> select the script you want to run and give it a display name -> OK
Now you can run it with the green "Run" button. The green bug button (next to the run button) will run it in debug mode.
Remark: next to the run button you can monitor the script/configuration you run by selecting it's display name.
If you create run-time configuration then after pressing the run button (green "play" icon) you will get the desired result: your code will give you output in a console which opens atomatically at the bottom.
You can create many different configuraions for run and debug within a single project.
Here is a link from PyCharm's web help which covers the run/debug configurations:
http://www.jetbrains.com/pycharm/webhelp/run-debug-configuration-python.html
A possible way of manipulating the variables using debug mode and evaluate expression window is added in comment but I missed one detail: to see the result of your interactive code execution you have to switch from Debugger to Console output; mode tabs are on the top-left side of the bottom pane.
The way I do it is a create my script in the editor, call it myfirst.py, eg
print "Hello"
a= 1234
then in the console I run:
reload (myfirst)
To check on the variables use:
>>> myfirst.a
Not perfect but that's pyCharm for you. If you want a pyScripter like experience which I think is more useful you can try spyder2.
It may also be a good option for you to use the magic command
%run scriptname.py
in the ipython console (including the %-character). Compared to Cntrl + Alt + E you also get clean information on errors in your code.
Due to autocomplete it's also typed in a second and you can use this in any environment with an ipython shell. For me as a scientist who often uses python to explore data, this is a good option.
With your program in the editor:
Run - Edit Configurations
Then under Execution check the box for "Run with Python console".
When you run the program from the green arrow it will run in a console. After the run all your objects are available to examine and play with.

Categories

Resources