&符号“&"在 VSCode 中运行任何 Python 脚本时出现语法错误?

&符号“&

问题描述:

在 VSCode 中,我通常使用 Python 扩展并右键单击 .py 脚本并选择在终端中运行 Python 文件"来运行 Python 脚本.在今天之前,这种方法工作正常,但现在我遇到了以下问题...

In VSCode, I typically run a Python Script using the Python extension and right clicking a .py script and selecting "Run Python File in Terminal". Before today this method worked fine, but now I'm experiencing the below issue...

$ & C:/Users/.../Python/Python37-32/python.exe c:/.../test.py
bash: syntax error near unexpected token `&'

现在我无法使用这种方法运行我的 python 脚本.我可以看到错误的原因,我只是不确定 为什么 VSCode 在该符号前面加上前缀,以及它之前是否这样做过.

Now I can't run my python scripts using this method. I can see the cause of the error, I'm just not sure why VSCode is prefixing that ampersand, and whether it was doing that before or not.

我在玩 virtualenv,也许这就是原因,但即使虚拟环境未处于活动状态,我也会遇到此问题.我已经重新启动了 VSCode 和我的电脑,它似乎坏了.

I was playing around with virtualenv, and perhaps this is the cause, but I'm experiencing this issue even when the virtual environment is not active. I've restarted VSCode and my PC, it appears to be broken.

通过将我的 Python 扩展版本降级到以前的版本来解决此问题.似乎最新版本(仅在几个小时前发布)被窃听了(至少对我而言).

Fixed this by downgrading my version of the Python extension to the previous version. It appears as though the latest version (released only hours ago) is bugged (for me at least).