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

Python Interactive window does not use the python associated with the current file when starting #3865

Closed
DonJayamanne opened this issue Nov 1, 2018 · 27 comments
Assignees

Comments

@DonJayamanne
Copy link
Contributor

Currently we aren't passing the resource: Uri value into most methods.
This would result in various parts of the extension not working correctly in a multi-root environment (current code will pick settings from first available workspace folder).

Examples:

This only applies to multi-root environments.

@rchiodo
Copy link
Contributor

rchiodo commented Nov 2, 2018

The problem is what would we pass for the resource? The iPython kernel applies to all open python files. Otherwise we'd have to have multiple kernels running? I guess that's an option too.

@DonJayamanne
Copy link
Contributor Author

The problem is what would we pass for the resource?

The uri of the open python file.

The iPython kernel applies to all open python files. Otherwise we'd have to have multiple kernels running? I guess that's an option too.

Yes, else here's the bug:

  • User opens a multiroot workspace with two workspace folders
  • Workspace A - No python or has Python without jupyter
  • Workspace B - Has Python with Jupyter
  • User open a file from Workspace B, and runs a Cell
  • Error - No jupyter installed, etc
    But Jupyter is installed, its just that we're using the wrong python interpreter.

@rchiodo
Copy link
Contributor

rchiodo commented Nov 2, 2018

I think we'll have to do something like look at all of the active python files and find the one with jupyter installed in it.

@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Nov 3, 2018

That's wrong. The user should be making the decision, not us.
The whole point of integrating with the extension is lost, the user decides what python version is to be used in the current workspace, we should maintain that, we could display a prompt asking them if they would like to change it.

Else we have some major inconsistencies with the, python extension.

@rchiodo rchiodo changed the title DataScience code needs to make use of resource appropriately Python Interactive window does not use the python associated with the current file when starting Mar 8, 2019
@rchiodo
Copy link
Contributor

rchiodo commented Mar 8, 2019

We might also need to allow the user to pick if say they start without opening a file first or even if there are multiple.

@ollema
Copy link

ollema commented Jun 6, 2019

Is this in the pipeline for some future release? 🙂

@rchiodo
Copy link
Contributor

rchiodo commented Jun 6, 2019

Not at the moment, no. Our 'backlog' or 'inprogress' pipelines are what we're currently working on.

It does have a lot of votes though.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 6, 2019

I'm moving it to New Issues so we triage it again.

@ollema
Copy link

ollema commented Jun 6, 2019

are these pipelines public? not sure where I can find them

@greazer
Copy link
Member

greazer commented Jun 6, 2019

To start, let's just make sure we're honoring the active python version on first start of the interactive window.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 6, 2019

@ollema I think you have to install zenhub to see the issues? Not sure.

Here's what it adds for me:
image

@rchiodo rchiodo self-assigned this Jun 17, 2019
@rchiodo
Copy link
Contributor

rchiodo commented Jun 27, 2019

This is the branch where I started this work:
https://github.com/microsoft/vscode-python/tree/rchiodo/multiple_workspace_kernel

@rchiodo
Copy link
Contributor

rchiodo commented Jul 2, 2019

The resolution of this should let the user

  • Pick any python that supports jupyter as a kernel
  • Pick any kernel installed on the machine that's running jupyter (well that's python based for now). Meaning a remote jupyter will let you pick the kernels installed, as well as a local jupyter.

@dnlwgnd
Copy link

dnlwgnd commented Aug 6, 2019

I just ran into this.

I am working with a workspace that includes multiple folders.
Each of those folders has its own venv (via pipenv), that gets correctly detected by vscode. Normal .py files execute as expected with the selected interpreter. Also bottom-left displays the correct interpreter.

Now in a file that contains cells (imported from a .ipynb file), running a cell is supposed to start up the jupyter server. Now I do expect it to look for the jupyther installation in the currently selected interpreter (venv), but instead it tries to find it in the interpreter version assosiated with the topmost folder. If this folders interpreter does not have jupyter installed, it will issue a warning and (interestingly) uses the closest match, which is a interpreter in some of the other subfolders.

I saw other issues with conda environments, but I do use a plain python install.
I am on windows 10, running vscode inside the WSL.

I could test any fixes, if needed.

@rchiodo
Copy link
Contributor

rchiodo commented Aug 6, 2019

The fix isn't that hard, just haven't had the time to finish it yet. I'm going to move this bug back to triage to see if we can bump up the priority.

@greazer greazer assigned IanMatthewHuff and unassigned rchiodo Aug 8, 2019
@greazer
Copy link
Member

greazer commented Aug 8, 2019

@Markpajr
Copy link

Markpajr commented Sep 2, 2019

I believe this is the same issue I'm having. I have two environments through anaconda, Both have jupyter. Script will run through the terminal in vscode, but not through Python interactive. Using sys.version shows python interactive is using a different interpreter than VSCode overall.

Is anyone aware of a fix for this?

@TeraInferno
Copy link

While a proper fix is in progress, a work around is to create a new workspace with a single root, with the root being the project you want to run jupyter interactively. It works in this reduced use case

@IanMatthewHuff IanMatthewHuff removed their assignment Sep 9, 2019
@jetilton
Copy link

@TeraInferno can you expand on the below.

While a proper fix is in progress, a work around is to create a new workspace with a single root, with the root being the project you want to run jupyter interactively. It works in this reduced use case

I have some environments that run a Python Interactive shell and some that do not. I cannot pin down the difference between them What is the best current way to start a new project with a virtual environment in vs code that can use Python Interactive?

@rchiodo
Copy link
Contributor

rchiodo commented Oct 21, 2019

The spec part of this issue is based on how to pick a kernel. We're going to solve both allowing per file python selection and kernel selection at the same time.

@greazer
Copy link
Member

greazer commented Nov 16, 2019

This is being addressed through #1379

@greazer greazer closed this as completed Nov 16, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 23, 2019
@rchiodo
Copy link
Contributor

rchiodo commented Feb 5, 2020

Actually this wasn't entirely addressed through #1379. We still don't use the file to pick the environment.

@rchiodo rchiodo reopened this Feb 5, 2020
@rchiodo rchiodo unassigned jmew Feb 5, 2020
@rchiodo rchiodo self-assigned this Feb 13, 2020
@IanMatthewHuff IanMatthewHuff self-assigned this Feb 25, 2020
@IanMatthewHuff
Copy link
Member

This doesn't look resolved to me.

What I did

Folder A
Folder B

Create envA in A and envB in B

Opened up a workspace with both folders added to it. Selected envA for a file test.py in A and envB for a file test.py in B. When I did "run selection / line" in test.py in file B instead of using envB it tried to install ipykernel in envA.

@rchiodo
Copy link
Contributor

rchiodo commented Feb 25, 2020

Did you verify that the file in B that the environment actually stuck? Seems there's a bug in the base extension where you have to switch back and forth between the files.

@rchiodo
Copy link
Contributor

rchiodo commented Feb 25, 2020

For example, what does 'Python: Run in terminal' do?

@IanMatthewHuff
Copy link
Member

Sorry will report back in just a bit. Having funny issue with my python virtual envs.

@IanMatthewHuff
Copy link
Member

@rchiodo . Good call. I'm pretty darn sure that I had the scenario right, so it was probably that core bug. This time I swapped back and forth a few times and ran both of them in the terminal and it did launch with the correct env this time. Validated.

@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants