-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Run Python file in Terminal with error "& was unexpected at this time." #13466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@bububut, thanks for letting us know about this. I was not able to reproduce the problem with the following steps:
Here's what I see in my terminal pane:
What is the actual text in your terminal pane? |
@ericsnowcurrently I cannot reproduce the problem myself after I restarted vscode today, so I'll close the ticket. Thanks for your help! |
I just randomly started getting the issue in 1.50.1
It's a bit annoying trying to fix, as all the issues keep getting closed without any actual solution |
Getting exact same issue today, this doesn't seem to have been resolved. Version: 1.53.2 (user setup) |
For me the issue resolved by redirecting the console path to the target file that I would try to execute. Both cmd and python console in VSCODE are targeting the same target path. |
Same here. VS Code: 1.56.0 Everything worked well until some recent update. Now there isn't Example:
|
How do you redirect the console path? |
#16175 is the currently open issue about this - I'm getting the same issue. Temporarily need to use powershell as the integrated terminal. |
@Cubostar Soz but it;s been so long and I really can t remember what was the exact process that I followed... I check my integrated terminal configurations though and I am temped to send you a screenshot.. (ctl-shift-P and type terminal.integrated.default -> edit in settings.json). Make sure you are in the right console directory when you apply changes in your settings (both Workspace and User). After changing the file, right click on file.py and choose "Open in integrated terminal" option. ps:If that fails, just re edit the file and paste the previous values stored before changing anything. |
I am getting the same error. |
Me too |
iam also getting the same error |
I did this and edited the file in MS VC, so the full line looked like this (due to special char): Worked for me! |
Indeed, I didn't notice the double backslashes weren't included when I copied and pasted the string. |
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe" There, you need 3 backslashes in the original string to generate 2 on the web page. |
I had a friend having the same problem today and I told him to add these two lines into the settings.json file and it solved the problem. These settings just let the VS Code terminal know the right path for Anaconda, and also activate the environment automatically when you run your Python file in the terminal. |
yeah this worked for me too. |
I just had the same problem after removing the line that everyone is talking about.
Would be great to find the actual bug or problem that need to be solved |
Just got this error as well. Happened after I couldn't interrupt a process running in terminal using Ctrl+C and forcefully closed it. Code is able to be ran as per normal using powershell though |
Environment data
Expected behaviour
right click in Python file and choose "Run Python File in Terminal" to get the file run
Actual behaviour
it inserts a '&' symbol at the beginning of the command and the commands failed with "& was unexpected at this time."
my terminal is cmd.exe
It's the same problem as #5916
I believe it has been solved and that issue is closed, don't know why it happens again now
The text was updated successfully, but these errors were encountered: