Nov-07-2018, 04:27 PM
New information:
The above is still valid for re-installation, and I have been running without issue until yesterday, when the original:
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.
some time later:
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.
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.
- Close project 1 (virtual environment) using 'File --> Close Folder' to close the the first session (while terminal window still open)
- exit VSCode using 'File --> Exit'.
- (sometime later, but during same login session) Open VSCode from GNOME icon.
- 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.
- 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.
- Using command palette, I select the proper interpreter (or so I think) by selecting (cached)./venv/bin/python.
- Everything appears OK.
some time later:
- I try compiling using 'Run python file in terminal', and get an error message that I am missing a package.
- 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.
- Whenever exiting project by using 'File --> Close Folder', first close terminal window.
- Open project 2 (from welcome menu shortcut). If you forgot to close terminal window from previous session, close now.
- Select the python interpreter for current session.
- Now, only after selecting python interpreter, open terminal window, using either View --> Terminal' or 'Run python file in terminal'.
- all really will bo OK now.