Skip to content
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

Using play button after running selection in terminal use DOS syntax at Python ">>>" #11435

Closed
JimCallahanOrlando opened this issue Apr 27, 2020 · 9 comments
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on

Comments

@JimCallahanOrlando
Copy link

Visual Studio Code Python Extension Play button seems to be using DOS syntax on Python command prompt ">>>".
Does not matter which command line is select in terminal (Python or Cmd)

===
I can highlight lines and run Python code
(from command pallet "Python: Run Selection/Line in Python Terminal").

===
But, when I try pressing the PLAY BUTTON I get message (note triple python prompt, but DOS/cmd syntax)

">>> C:/Users/JimCa/AppData/Local/Programs/Python/Python38/python.exe c:/Users/JimCa/Documents/campaign/CampaignFinance/hello.py
File "", line 1
C:/Users/JimCa/AppData/Local/Programs/Python/Python38/python.exe c:/Users/JimCa/Documents/campaign/CampaignFinance/hello.py
^
SyntaxError: invalid syntax"

===
The paths are correct (even though AppData is hidden)

===
"Run without debugging" from the Run menu works

===
From Help About:

Version: 1.44.2 (system setup)
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T16:36:23.138Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

Environment data

  • VS Code version: 1.44.2
  • Extension version (available under the Extensions sidebar): 2020.4.74986
  • OS and version: Windows_NT x64 10.0.18363
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.2 (from Python.org)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): XXX
  • Value of the python.languageServer setting: XXX

Expected behaviour

Run hello.py

Actual behaviour

">>> C:/Users/JimCa/AppData/Local/Programs/Python/Python38/python.exe c:/Users/JimCa/Documents/campaign/CampaignFinance/hello.py
File "", line 1
C:/Users/JimCa/AppData/Local/Programs/Python/Python38/python.exe c:/Users/JimCa/Documents/campaign/CampaignFinance/hello.py
^
SyntaxError: invalid syntax"

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. create hello.py
  2. file save
  3. highlight code and select "Python: Run Selection/Line in Python Terminal"
    from command palette -- codes runs OK
  4. Notice setting of terminal (is it "Cmd" or "Python" either setting will cause error;; if it is set to "CMD" it will flip to "Python" after pressing PLAY button)
  5. Press the triangular PLAY button
  6. Will receive syntax error message with text that shows CMD/DOS syntax on a Python ">>>" prompt. The CMD/DOS syntax has the correct file paths, but does not belong at a
    Python ">>>" prompt

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python) NONE

XXX

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

XXX
@JimCallahanOrlando JimCallahanOrlando added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Apr 27, 2020
@JimCallahanOrlando
Copy link
Author

Good news and bad news.
Good news per advice from Chris Sams @cssams I uninstalled python extension,, quit VS Code, restarted VS Code and reinstalled python extension and problem was cleared up,
but
then I tried loading a Jupyter Notebook .ipynb file which had a kernel issue and the problem recurred -- so the Play button issue seems to be a side effect of a Jupyter Notebook malfunction.

I went through another cycle of reinstalling Python extension and play button issue fixed again.
So, as long as I don't encounter Jupyter Notebook kernel malfunction PLAY button is fine.

@Diogo-Rossi
Copy link

As long as I know, the "play button" (Run Python File in Terminal), in this extension, runs the command python file in the integrated terminal. The line below, that you posted, shows that:

>>> C:/Users/JimCa/.../Python38/python.exe   c:/Users/JimCa/Documents/.../hello.py
    ↑______________ python _______________↑   ↑______________ file _______________↑

If you run this command inside a Python REPL, it will give you that error.

And I also experienced that the the "play button" will create a terminal named "Python" before run the above command. If this terminal already exists, it will be used.

So, if you have a terminal named "Python" running CMD, the above command will be ok. If you have a terminal named "Python" running python REPL, the above command will give you an error.

@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Apr 29, 2020
@karrtikr karrtikr changed the title VS Code Python Extension PLAY BUTTON seems to be using DOS syntax at Python ">>>" Using play button after running selection in terminal use DOS syntax at Python ">>>" May 4, 2020
@karrtikr
Copy link

karrtikr commented May 4, 2020

Hey everyone. This is just to inform you that we can confirm the issue.
Using command Run selection in Python terminal followed by clicking the play button results in this error, as the command is sent to the same terminal instead of creating a new one.

@karrtikr karrtikr removed their assignment May 4, 2020
@Diogo-Rossi
Copy link

Just to give another information: the logic I've posted before "If this terminal already exists, it will be used" is not always true.

I had see it in another issue here in Github (sorry, can't find it to refer here)

I tried to create a new CMD terminal and renamed it with "Python". But the "play button" created another terminal named "Python" anyway. (figure below)

So (at least for my case), the logic that works is:
If this terminal already exists - and it was created with the play button - it will be used, otherwise the "play button" will create a new terminal named "Python" before run the above command.

image

Is it ok?

@karrtikr
Copy link

karrtikr commented May 4, 2020

Yes, that's expected. Thanks for helping others earlier!

@cardinalgeo
Copy link

Hi all! Are there any updates on this thread? I've also run into the issue described, and though uninstalling and reinstalling the Python extension resolves it, the problem very quickly reemerges.

@Diogo-Rossi
Copy link

Diogo-Rossi commented Jul 6, 2021

It will be good if the the command "Run Python File on terminal" could recognizes that there is an already active opened Python terminal running. This would avoid this issue.

As an alternative, the command triggered with the play button could run the reload() function on the active file as a module.

At least it could let us customize this command, or hide the Play Button.

@karrtikr
Copy link

Closing as dup of #2997.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2022
@JimCallahanOrlando
Copy link
Author

JimCallahanOrlando commented Dec 19, 2022 via email

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

5 participants