How to get terminal size in Spyder? - python-3.x

I am trying to get the terminal size using the function shutil.get_terminal_size().
This works well in a Python console or an Ipython console, but not in the Ipython console inside the Spyder editor, and I don't understand why.
Any ideas ?
Thanks in advance!

(Spyder maintainer here) Spyder consoles are not "real" consoles, i.e. they are not based on the same technologies as those used in terminal-based consoles (such as cmd.exe or Terminal.app). Therefore, shutil.get_terminal_size() doesn't work as expected.
Actually, our console's width is fixed at 80 characters and right now (October 2020) that limit can't be changed.

Related

Problem integrating Terminality with sublime text 3

I installed Terminality (https://github.com/spywhere/Terminality) using package control in sublime text 3 on macOS. In it's github page, it's showing that Terminality can work interactively like terminal. But, when I run a c program, it's taking all the input once and printing all the output once (like it works in competitive programming environments like Hackerrank or Codechef). It's working perfectly fine for python. Can anyone help me tweaking it so that it works interactively for C also? Thanks in advance!

vscode on WSL issue: editing cursor goes backward when opening bracket or braces

I'm running vscode into a Debian WSL subsystem on top of my Windows 10 workstation, thanks to Xfce4 window-session and vcXsrv X server.
I'm working on a Python 3 project and I have a strange behavior with my vscode editor running on WSL that I can't reproduce with either the native Windows or Linux build : Let's say in want to access a dict key, I'd type the following code:
my_dict[
here I'm expecting IntelliSense auto-close the bracket and keep the cursor between the brackets. This what usually happens (at least with my native vscode on Windows and on my vscode on my /real/ Linux box). But this is not what happens on my WSL !
Seems the cursors goes backward before actually typing the open bracket so the bracket is typed one char earlier, and finally don't close the bracket, To be clearI get the following typed in the editor:
my_dic[t
If I workaround by typing a space before typing the opening bracket, I get the same behavior but this time as the earlier char is a space IntelliSense is functionning /almost/ as expected, forwarding the typed space at the end of line (bellow the '$' represents EOL) :
my_dict[] $
I experienced this with brackets ([]) and also braces ({}), with python code and also JSON files, so I don't wonder this is related to language extension.
Last but not least, the only installed extension, is "Python 2019.1.0" by Microsoft and the setup is full stock with no customization at all...
I spent hours reading vscode documentation and browsing for similar issue, with no luck (maybe wrong keywords ?), so any hint will be appreciated, thanks !
In the backend, you're still utilizing conhost from the Windows Console to run all your terminal commands. Some cursor behaviors don't work properly in earlier builds of Windows on WSL (but do work fine on Windows). Try to update to the latest and see if you still encounter the issue. If you do then, check for an issue in https://github.com/Microsoft/console and create one if not there.

Tkinter layout changes from Spyder to Command Prompt

I have built a simple GUI in tkinter that goes through an algorithm to fit Radial Velocity data. Everything works fine in Spyder, however when I try to run the file in command prompt the GUI's dimensions change drastically. This is how it is supposed to look and how it looks in Spyder. This is how it looks when it's run in command prompt. The plots that are produced show the same behavior described. I've tried setting all the windows in Tkinter so that they are unable to be resized. I'm not sure what else to try. Is there a way to fix this? I am on Windows 10 64bit, Python 3.5.4, and Spyder 3.2.5.
I found out what the problem was. It's due to the fact that Spyder automatically overrides high DPI scaling, whereas both Python.exe and Pythonw.exe do not. The solution was to check the 'Override High DPI Scaling behavior' option under the compatibility tab for both python.exe and pythonw.exe.

Pycharm - Waiting for REPL response when python console using IPython

Response times in a PyCharm Python Console are unbearably slow when the console is configured to use IPython. This wasn't the case in a previous installation. When the Python Console is not configured to use IPython, and uses IDLE, it performs normally.
The poor response time seems to be linked to the REPL response function, as depicted in the image below. When the REPL response dialog completes, a background process continues to run for several minutes.
Since this was not a problem in a previous installation, the issue must be a result of a configuration change. However, the only thing I changed was to utilize a Conda env instead of a virtualenv.
Any ideas?
This issue was reported to JetBrains. The issue was duplicated and identified as a bug. The status of the issue can be viewed at:
https://youtrack.jetbrains.com/issue/PY-24880
Here is how to apply the "answer" found in the JetBrains bug filed by #vlmercado https://youtrack.jetbrains.com/issue/PY-24880:
Disable auto popup completions (in Editor->General->Code Completions)
Posting my comment as an answer, I have tried it now for a few days and had 0 REPL hangups.
Ubuntu but should work on every machine.
Go to: File----> Settings---->Editor---->General---->Code Completion
Uncheck Rank completion suggestions based on Machine Learning
That's it. Happy Coding.
Today I had the same problem in Pycharm2019.3 with Python3.8. It may have been caused by using miniconda instead of the full anaconda installation, because after installing the ipython package (with -conda install ipython) the long REPL waiting times have dissappeared.
I am not sure if it is solved by jetbrains, for me, it just randomly starts even after 1-2 hrs of coding,
I have tried every options found in Jet brains as well as Stack Overflow like checking and unchecking of 1,2 in combination as shown in image. Have experienced same with the code completion option as well,
These options might help:
Settings: File > Settings > Build, Execution, Deployment > Console
Ipython Setting option:
Run with Console option:

Python code terminated in Pycharm with exit code 1073741819

Python version: 3.4
Hi, I was running a small Python code in Pycharm, but it was terminated with the exit code 1073741819.
I've tried the same code in the Python command line and Anaconda, and both worked. Any idea why Pycharm has the problem, and how can I get it work in Pycharm? Thanks a lot.
Its too late to answer now, but maybe it helps someone else. My code also worked right with command line but not inside pycharm, it usually happens when we switch between different projects on PyCharm.
I fixed it by:
1- Restarting the Pycharm and reloading the project into it.
2- Clearing the heap memory by clicking at this in status bar:
and now it works pretty fine.
P.S: If this indicator doesnt appear then visibility of this section in the Status bar is defined by the Show memory indicator check box in the Appearance page of the Settings/Preferences dialog. It is not shown by default.

Resources