Python Forum
VSCode can't select interpreter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VSCode can't select interpreter
#7
New information:
The above is still valid for re-installation, and I have been running without issue until yesterday, when the original:
Quote:however when I try to run by choosing 'Run python file in terminal' The virtual environment interpreter is not being used, I know this as it is saying a package isn't installed, but it is (in venv)
issue reoccurred. After a lot of digging I found something very subtle was causing my problem:

here's the sequence of events that caused the issue: when switching from project to project (all with virtual environments), occasionally the compiler used when i chose 'run python file in terminal' was not synced with the virtual environment.

  1. Close project 1 (virtual environment) using 'File --> Close Folder' to close the the first session (while terminal window still open)
  2. exit VSCode using 'File --> Exit'.
  3. (sometime later, but during same login session) Open VSCode from GNOME icon.
  4. Select project 2 from welcome menu, using shortcut. Upon opening, the terminal window automatically opens (this was the state I left it upon exit from project 1), but it's in the proper directory for project 2, however it's not using the proper virtual environment.
  5. From terminal window, I issue command to start venv: . ./venv/bin/activate. The virtual environment starts, and I see python -V using it and also see pip -V using it, so I feel ebevrthings ok with the terminal.
  6. Using command palette, I select the proper interpreter (or so I think) by selecting (cached)./venv/bin/python.
  7. Everything appears OK.

some time later:
  1. I try compiling using 'Run python file in terminal', and get an error message that I am missing a package.
  2. Switch to terminal window and type 'pip list'. The package is there.

So what went wrong?
It appears that the sequence of events needs to be modified as a work around for what appears to be a subtle bug.
  1. Whenever exiting project by using 'File --> Close Folder', first close terminal window.
  2. Open project 2 (from welcome menu shortcut). If you forgot to close terminal window from previous session, close now.
  3. Select the python interpreter for current session.
  4. Now, only after selecting python interpreter, open terminal window, using either View --> Terminal' or 'Run python file in terminal'.
  5. all really will bo OK now.
I use same name for all of my virtual environments, and that probably has something to do with the problem. I will update the github VSCode posting I made to reflect the new observations, in the meantime, following the final sequence above will suffice.
Reply


Messages In This Thread
VSCode can't select interpreter - by Larz60+ - Oct-24-2018, 09:07 AM
RE: VSCode can't select interpreter - by buran - Oct-24-2018, 09:18 AM
RE: VSCode can't select interpreter - by Larz60+ - Oct-24-2018, 03:42 PM
RE: VSCode can't select interpreter - by snippsat - Oct-24-2018, 05:18 PM
RE: VSCode can't select interpreter - by Larz60+ - Oct-24-2018, 06:11 PM
RE: VSCode can't select interpreter - by Larz60+ - Oct-27-2018, 09:31 AM
RE: VSCode can't select interpreter - by Larz60+ - Nov-07-2018, 04:27 PM
RE: VSCode can't select interpreter - by Larz60+ - Nov-12-2018, 05:12 PM
RE: VSCode can't select interpreter - by Larz60+ - Nov-12-2018, 11:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,310 Feb-14-2019, 08:34 PM
Last Post: woooee
  All of a sudden Pycharm doesn't run anymore (select valid interpreter) Luke_Drillbrain 1 5,364 May-04-2017, 07:30 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020