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

Run python file in pipenv environment fails #4245

Closed
DonJayamanne opened this issue Jan 31, 2019 · 3 comments
Closed

Run python file in pipenv environment fails #4245

DonJayamanne opened this issue Jan 31, 2019 · 3 comments
Assignees
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on

Comments

@DonJayamanne
Copy link

  • Use pipenv for current environment
  • Run python file in terminal
    • Open python file , right click and use the menu option Run Python file in terminal
    • The terminal will now open automatically
    • Python Extension will send the text pipenv shell to activate the environment in the terminal
    • The python extension will send the text <python interpreter> <file name> to the terminal
    • Unfortunately there's a race condition here, pipenv shell has not yet completed, and the commands sent later get swallowed up
  • End result, file doesn't run in terminal

Causes:

  • There's no way to determine when terminal has completed processing previously sent commands.
  • VSC is sending messages to the terminal, when its busy

Solutions:

  • Python extension adds a delay between the two commands being sent to the terminal (this is what we do today). However pipenv shell takes longer than other activation routines, hence we need a much longer delay (i.e. a bigger magic number), a work around.
  • Or, VSC provides some api to let us know the terminal is ready to accept input.

microsoft/vscode#67693

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jan 31, 2019
@DonJayamanne DonJayamanne added the important Issue identified as high-priority label Jan 31, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 31, 2019
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-terminal triage-needed Needs assignment to the proper sub-team labels Jan 31, 2019
@DonJayamanne DonJayamanne self-assigned this Jan 31, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 31, 2019
@DonJayamanne DonJayamanne added the P0 label Feb 1, 2019
@powellquiring
Copy link

I believe I'm stuck on this. In the terminal I see this:

~/om/github.ibm.com/pquiring/vpcibm$ pipenv shell
Launching subshell in virtual environment…
 . /Users/pquiring/Envs/vpcibm-spz4F-UA/bin/activate
~/om/github.ibm.com/pquiring/vpcibm$  . /Users/pquiring/Envs/vpcibm-spz4F-UA/bin/activate
(vpcibm) ~/om/github.ibm.com/pquiring/vpcibm$

How do I work around this? Is it possible to just hard code the python environment? I've had things set up with a specific python and it worked in the past few weeks, but this no longer works:

    {
      "name": "Python vpcibm.py",
      "type": "python",
      "request": "launch",
      "program": "vpcibm.py",
      "console": "integratedTerminal",
      "pythonPath": "/Users/pquiring/Envs/vpcibm-spz4F-UA/bin/python"
    }

The terminal window displays:

 . /Users/pquiring/Envs/jupyter-f2acqZjX/bin/activate
~/om/github.ibm.com/pquiring/portfolio-inbound/scenarios/roadmap/vpc/jupyter$  . /Users/pquiring/Envs/jupyter-f2acqZjX/bin/activate
(jupyter) ~/om/github.ibm.com/pquiring/portfolio-inbound/scenarios/roadmap/vpc/jupyter$

@DonJayamanne
Copy link
Author

DonJayamanne commented May 23, 2019

Solution:

Use new VSC API (proposed API at the time of writing this) to check what information has been written out into terminal before sending other commands.

See here microsoft/vscode#67693 (comment)

@DonJayamanne DonJayamanne added regression Bug didn't exist in a previous release needs PR and removed needs upstream fix important Issue identified as high-priority regression Bug didn't exist in a previous release labels May 23, 2019
@github-actions github-actions bot removed the needs PR label Aug 9, 2022
@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@karrtikr
Copy link

Closing in favor of #16988, we also are no longer using pipenv shell command.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 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