What happened to the Python interactive window? - python

I am working on MacOS v10.14.6 and using the Python interactive window of VScode v1.38.1.
I write code in a .py file and use #%% to create cells and shift+enter to run them in the interactive window.
Today the layout of the interactive window changed, but I didn't do any update and I did not change my settings.
It now shows icons on the top left (as on the screenshot below) instead of showing them on the top right, as it was the case before (as shown in the tutorial).
To me it looks like that doing shifts+enter now launchs a jupyter notebook similar to the one now supported by vscode, because the icons are similar. See the ones on this tutorial here.
The really annoying thing is that now my plots have a dark background, instead of a white one as it was the case before.
I checked and the option python.dataScience.ignoreVscodeTheme is still set on True.
Do you have an idea what happened ?

Thanks for the info Louis. So you are still seeing the interactive window there, not the new notebook experience, we just made some tweaks to the icons and icon locations to match the interactive window up better with the new experience. However while much of that is expected we did break the ignoreVscodeTheme setting. We have an issue filed on that there and it's on our immediate list to fix. Sorry about that, and thanks for reporting.
https://github.com/microsoft/vscode-python/issues/7847

Related

how to clear the screen in pycharm

I know these are questions: this and this and this. I have tried all of these methods in pycharm, but they either a) not work or b) I get a weird character on my screen, that looks like a 0 with diagonal line going through it. I can't copy it for some reason, so I can't show you.
For instance this:
import os
from time import sleep
print("lots of text")
sleep(5)
os.system('cls')
What should happen in the above is tht the message should be displayed for 5 seconds then disappear, but all I get is that weird character... In contrast when I ran my python program from command line, it worked as expected i.e. the screen cleared. I am very confused.
So my questions are:
Why don't any of them work in pycharm?
What does work in pycharm?
Ok, so, I have been having this problem as well — after scouring the internet, the os commands work BUT you need to enable the terminal emulator.
In the PyCharm toolbar, click Run, Edit Configurations, and the toggle for "Emulate Terminal in Output Console" should be under Execution in the pop up. Emulate Terminal toggle
I had to get help from the PyCharm team on this one, so here's to them responding at lightning speed.
Answer
The cls command doesn't work on a standard pycharm project because it is an IDE and certain os commands don't work in the same way it would with the windows command line.
There is currently no way to clear the console output in PyCharm, other than to manually do it by using the cls command through the terminal in PyCharm or through a keyboard shortcut set through the pycharm preferences menu. You can try to emulate a keyboard shortcut, but this would be difficult, and unless you absolutely need it, I would not recommend clearing the terminal output after a program is run.
References and Additional Links
https://teamtreehouse.com/community/clear-screen-for-pycharm-as-if-it-were-on-console-or-cmd
I don't know in which version of PyCharm this was introduced. I guess it must have been after this question was asked.
The way to clear the PyCharm Python Console is by using the context menu. Right mouse click in the upper part of the console (where the lines with >>> prompts are closer together) and select Clear All.
Alse see this PyCharm Support Community article.
Incidentally, none of the questions linked to in the OP's original post relate to PyCharm and do not answer the OP's question.
cls only temporarily clears it. Next command brings back all previous messages. The best option is to right click on the Terminal and choose Clear Buffer

Column Names faint or invisible for python Datatable view() on MacOS

I'm giving the H2O datatable a try and am intrigued by the view() feature. It looks like a handy way to navigate a dataset:
The navigator is great: you can use g2000 to go to row 2000 . But the column headers are faint - almost invisible. The image above is on macos terminal. Below is iTerm: and the headers are invisible there:
Given my interest to make the datatable.view() an integral part of my development process - since I prefer ipython to jupyter notebooks it would be helpful to find a solution to this. Has anyone discovered maybe a terminal setting or two that would help?
This problem has been reported before (see https://github.com/h2oai/datatable/issues/1793), but it was fixed in datatable v0.9.0 released in July 2019.
One possibility why you may still see faint colors is that your terminal preferences could be misspecified. Please check your terminal preferences and make sure the "Bold Text" is set to the color that has high contrast with your terminal's background.
Based on suggestion/comment from #GreenCloakGuy I have tried out applying different Profiles to the Terminal window. This is a working solution. In addition I learnt that pressing CMD-I allows dynamic switching of profiles in Terminal. That's useful!

Scroll python function help in Vim

I am learning to use vim as an IDE for Python and followed this tutorial to setup my .vimrc file. My setup is working fine.
Here, vim shows me the help for np.random.randint, but I could not figure out how to scroll through the displayed help and read about the other parameters. This feature is introduced by YouCompleMe (as far as I understand), so possible solution might be to change some configuration for it.
Since, I am new to this, I am not even sure what this feature is called (auto complete does not seem to be the right name for displaying help) and therefore was not able to find help on web-searching.
Any help will be appreciated, thanks.
YouCompleteMe uses the Jedi library for Python. If you want to install Jedi alongside YCM, this answer has some advice on how to do so.
In any case, the extra docstring information is opened in a preview window, so you should be able to switch to it in normal mode (ctrl-w w) and scroll like a regular Vim window.
If the buffer disappears when you exit insert mode, here's some sample solutions:
If you're okay with enabling mouse controls, add set mouse=a to your VIMRC, and then you can click between the buffers while typing and even scroll using your mouse wheel or trackpad.
Remove let g:ycm_autoclose_preview_window_after_completion=1 from your VIMRC, since that will remove the preview window when you enter normal mode. Then, switch to the window normally.
Change the default preview height. Just be aware that this might be annoying if you have limited screen space.

Plotly + iPython Notebook - Plots Disappear on Reopen

When I create a notebook with plotly plots, save and reopen the notebook, the plots fail to render upon reopening - there are just blank blocks where the plots should be. Is this expected behavior? If not, is there a known fix?
Check to make sure your notebook is marked as "trusted", either in the top-right corner of the notebook, or in the File menu.
My notebooks are trusted by default, but I managed to reproduce your observed behaviour by temporarily removing my ~/Library/Jupyter/nbsignatures.db file, which forces Jupyter to run the notebook as untrusted. Clicking the tile in the top-right corner to trust the notebook fixed the issue for me.
This page in the jupyter docs, Security in notebook documents explains further:
The security problem we need to solve is that no code should execute just because a user has opened a notebook that they did not write. Like any other program, once a user decides to execute code in a notebook, it is considered trusted, and should be allowed to do anything.
I also meet this annoying issue. I find no way to reveal them on the notebook, but I find a compromise way to display them on an html page that is File -> Print Preview.
The reason as documented here:
Note: Default renderers persist for the duration of a single session,
but they do not persist across sessions. If you are working in an
IPython kernel, this means that default renderers will persist for the
life of the kernel, but they will not persist across kernel restarts.
As indicated in the troubleshooting documentation, "JupyterLab Problems" section, You have two options to solve the problem:
calling fig.show("notebook") instead of just fig.show().
If this problem is recurrent, you can use this:
import plotly.io as pio
pio.renderers.default='notebook'
Credits for here

Python IDLE. Auto-complete/Show completions not working

IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.
I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating not having them -- especially while trying to learn a new frame work and what class is associated with which methods, etc, etc..
Is there an easy fix to get IDLE auto-complete working again? I'm using python version 2.7.
Is there perhaps a simple editor I should look into? I've tried Vim, which was a little too heavy for my simple needs, Ninja, which I couldn't get to work for anything, and Sublime text 2, which I couldn't get my wxpython stuff to play with. What would a nice option be? Anything similar to Code Blocks would be cool, although, I'd be perfectly happy with IDLE if it would consistently work!
REQUESTED CLARIFICATION:
OK, so it seems I may have some of my terminology backwards. By non-interactive, I mean, for instance, right clicking on a python file and selecting "edit with IDLE". This brings up what I guess could be described as a text editor. You can enter all you code here. Once ready, you then hit F5, or select Run, and it launches (what I've been referring to as) the interactive terminal. It's here that you can type in code, press return, and instantly have that code evaluated.
What my question is referring to it the former, the part of IDLE where you edit the code. Sometimes while typing, after a . it will display the available methods, or after an open parenthesis it'll give hints as to the values expected. but the thing is, sometimes it does these things, sometimes it doesn't.
The only thing i found so far is that if an editing session of IDLE is connected with python shell (called "interactive mode" in the question, i.e. after an attempt to run the edited script) then "non-interactive" IDLE can autocomplete based on values in interactive window. For example, if I type
a = [];
a.appen
and then hit < Tab > it will do nothing, but if I previously type
a = []
in corresponding python shell, IDLE will autocomplete correctly.
So my only suggestion is import same modules with same names in python shell window in order to make them "visible" for non-interactive IDLE editor.
I had the same problem with IDLE, because I want to learn Qt and therefore autocompletion is very useful.
As it says in the settings of IDLE, you can trigger the autocomplete with "Control + Space", e.g. after a "QtGui.". Then a menu opens where you can arrow-scroll through the entries.
using the 'IDLE Editor window', you need to save and execute your code first.
The application running, turn back to the Editor window to use the auto-completion.
In my case, I had to open Options menu -> Extensions tab on the editor and look to make sure AutoComplete and other relevant options were enabled. They actually were, but by just clicking on 'Apply' even though I dint have to change anything did the trick for me.
Sometimes it has to do with the time you have to wait to get a suggestions.
When you go to options > extensions > general at completions popup wait you can change it to about 500ms.
In my case it was 2000ms by default.

Categories

Resources