VSCode Interactive Window "Run selection/line in Interactive Window" stopped working - python

I face the same problem as VS Code "Run selection/line in Python interactive window" not working at all, yet using Bisect to disable and detect the reasons through extensions didn't help. For me the problem started after VScode itself was updated yesterday.
VS Code version: 1.75.1
Python version: 3.9.13
Python VS Code extension: 2023.2.0
This command "Shift + Enter" just stopped working in full all of a sudden. It runs for a single line selected, but not for multiple. I cannot find why.
It is just time consuming to copy and paste the same code in the interactive code to run it.
Any ideas how I can fix it?

This problem seems to be caused by the 1.75.1 update. I solved this problem by using the old version of vscode. You can install the old version of vscode here.
By the way, you can also submit the problem to github/VsCode for repair.

Related

VSCode 'Run Python file' does nothing

Today I've encountered a very strange problem in Microsoft Visual Studio Code 2022. When I press the 'play' button to run my python code, nothing happens. This is true also with debugging.
There is no activity in either the built-in cmd or powershell terminals, but through these terminals I can run my code.
I have been using VSCode to write and execute Python code for months now with no issues - as recently as 10 hours ago! I have changed no settings or updated anything and I am at a loss.
I've checked the VSCode Python plugin and last update was 3 weeks ago, so unlikely that, but rolled it back anyway with no luck. I have also made sure my default terminal is cmd prompt, tried reloading and opening a new terminal, restarting PC, all to no avail.
Please help!
You can try the following:
use the shortcuts F5
install and use the code-runner extension
reinstall vscode

Spyder IDE with python 3.10 seems freezing when click run button, but it works fine if run a single line beforehand running the entire script

I have truble with last version of Spyder 5.4.0 with last version of Python 3.10.6.
Spyder version: 5.4.0 (conda)
Python version: 3.10.6 64-bit
Qt version: 5.15.2
PyQt5 version: 5.15.7
Operating System: Windows 10
Even if running a script like
print('Hello world')
when I click on the play green button, the IPython console seems freezing on this script, and it does not run for hours.
If I select this line of code and I run current selection or run the current cell it works fine. From this moment, it seems that spyder works fine, until at a certain point when I run it seems again freezing. I have to restart a new console and before running the script I have to run a single line or a single cell.
It seems that I have to 'activate' in someway the Python console in order to Spyder will run the script.
Does anyone have the same issue? How can I solve it?
I have tried to uninstall and reinstall both spyder and python many times, but it is useless.
After many trials, I noticed that there is something strange with IPython console. I noticed that when it hangs after running a code, if I delete all user variables, it worked fine.
Then I tryed to delete all variables before execution, and it work fine.
Therefore I discovered that a solution that worked for me is to go to preferences -> Run -> and untick the option 'Remove all variables before execution'
It is quite annoying because I have to do it manually every time before running, but in this way the spyder does not appear to hang anymore! I hope that the Spyder developers will solve it soon.
-
I automatically solved by typing at the beginning of any script these lines, inspired from the question Code to clear console and variables in Spyder :
try:
from IPython import get_ipython
get_ipython().magic('clear')
get_ipython().magic('reset -f')
import matplotlib.pyplot as plt
plt.close('all')
except:
pass
similar to Matlab in which you normally start your code with
clc
close all
clear all

Visual Studio Code not executing Python file

On my notebook, Visual Studio Code (VS Code) does not execute my python files anymore.
Yesterday it worked fine, then VS Code suggested me to update powershell from version 5.2 to 7. I did the update, know if I open my python file an try to run without debugging, the script is not executed.
Can someone help me with this issue?
My script for testing is only: print("Hello World")
What looks a bit strange for me is, that in the bottom right corner it shows the python version 3.6.10:
If I go to command prompt an choose Command Prompt, it shows python version 3.6.10 too:
But if I go to powershell (The first selection ind the picture above) it shows me another python version:
I hope someone can help me, I have no idea what to do anymore. Thanks!
Best regards,
Daniel
Added later:
Control bar which shows up for a very short time (Not even a second):
The python3.6 version is no longer supported in the latest debugger version.
Please use the new python version. Or install the historical version debugger.

Python 3.10 IDLE does not respond everytime I hit configure IDLE from options

I am a Windows 10 user, and had configured the Python 3.10 IDLE to dark mode and had added the Fira Code font to the IDLE a few days back (Through the Options menu). Then the Python IDLE was working fine; without issues.
However, each time after that when I try to go to 'Configure IDLE' from Options Menu, Python IDLE just freezes and then stops responding, until I manually close it. It then asks to run a Windows check and reports the error to Windows. I have tried uninstalling and reinstalling Python; however that did not work.
Image: Python has stopped responding (happens everytime I click on configure IDLE)
I am a Windows user and tried running python from cmd using the command: py -m idlelib to start IDLE from the command line to try and get an error report, however the same problem happens as mentioned above, and I do not get an error report when I close Python. I tried finding solutions in similar questions, however I did not understand what was going on. I also do not seem to figure out how 'running the Python IDLE' through the command line works, other than running it using the above command. Can someone please assist me on what to do next at this point, that would be of huge help :D
Try uninstalling the font. The Doesn't work part of the Editor compatibility list on https://github.com/tonsky/FiraCode includes IDLE. I suspect that the font is incompatible with tcl/tk. Your report is similar to
IDLE Settings window won't appear
See https://bugs.python.org/issue45103 for so far futile efforts to protect IDLE.
UPDATE: We were not able to reproduce the problem with FireCode. However, the BPO issue referenced above lead to a tcl/tk bug report that lead to a bugfix, at least for the Phaistos font, that is included in tcl/tk 8.6.12. This is included in the new Python 3.9.9 Windows installer and will be in the upcoming 3.10.1 installer. It might fix your issue with FiraCode.

Python Extension is not working in vscode bc of & command

I installed python then configured it for vscode by following docs of vscode, but they said I have to right-click on the editor after seeing a run Python in terminal. And I have to click on it.
But it only works in Powershell and when I tried to use it in cmd, then they said ----
D:\Program\Applications\C++>& D:/Compilers-Interpreters/Python38-32/python.exe d:/Program/Applications/C++/app.py
& was unexpected at this time.
D:\Program\Applications\C++>
I am using the C++ folder bc I was also trying to set up C++ by following the tutorial in vscode doc. Now can someone tell me how to fix this & problem????
This is a problem with VSCode, On the VSCode insiders it has been solved. You can wait for the next stable release of VSCode.
You can take this as a workaround for now:
Take adventage of terminal.integrated.shell.windows instead of terminal.integrated.defaultProfile.windows for now.
You can refer to here for more details.
It seems that for some reason & is being added to the beginning of your command, which makes the command invalid.
Upon testing, I actually am running into the same issue, suggesting it could be an issue with VS Code and Python. I would recommend using the debugger to run your program, which still seems to work. Just press F5 and select Python File: Debug the currently active Python file. Another way to do this is to define the launch.json configuration to automatically launch upon pressing F5.

Categories

Resources