question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Virtual Environment is not activated in the first terminal instance

See original GitHub issue

Environment data

  • VS Code version: 1.60.0 (user setup)
  • Extension version (available under the Extensions sidebar): v2021.9.1191016588
  • OS and version: Windows 10 / WSL 2 + Ubuntu 20.04
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Relevant/affected Python packages and their versions: n/a
  • Relevant/affected Python-related VS Code extensions and their versions:
  • Value of the python.languageServer setting: 2021.9.0

Expected behaviour

Virtual environment is recognized by VSCode, and activated in the terminal on startup

Actual behaviour

Virtual environment is recognized by VSCode (selected as the default interpreter automatically, but it is not activated in the terminal window which opens with VSCode. Opening more terminal instances activates them as expected.

Logs

User belongs to experiment group 'pythonaa'
User belongs to experiment group 'pythonJoinMailingListVar2'
User belongs to experiment group 'pythonJediLSP'
User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher'
User belongs to experiment group 'pythonTensorboardExperiment'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'pythonDeprecatePythonPath'
User belongs to experiment group 'pythonSortEnvs'
User belongs to experiment group 'pythonRunFailedTestsButtonDisplayed'
User belongs to experiment group 'pythonRefreshTestsButtonDisplayed'
User belongs to experiment group 'pythonRememberDebugConfig'
Error 2021-09-08 15:22:32: Custom .env is likely not pointing to a valid file [EntryIsADirectory (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/src/self/110yards/api/.env' (Error: Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/src/self/110yards/api/.env' that is actually a directory)
	at _handleError (/home/mike/.vscode-server/bin/e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff/out/vs/server/remoteExtensionHostProcess.js:94:160293)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async y.readText (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:9:315784)
	at async h.parseFile (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:408867)
	at async m._getEnvironmentVariables (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:412149)
	at async m.getEnvironmentVariables (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:412047)
	at async u.create (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:92999)
	at async S.create (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:94603)
	at async E.getActiveInterpreter (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:915819)
	at async f.updateDisplay (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:901640)
	at async f.refresh (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:901105)
	at async Timeout._onTimeout (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:37:30153)] {
  code: 'FileIsADirectory'
}
Python interpreter path: ./.env/bin/python
Error 2021-09-08 15:22:33: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/.config/Code/User/settings.json' (Error: Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu-20.04/home/mike/.config/Code/User/settings.json')
	at _handleError (/home/mike/.vscode-server/bin/e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff/out/vs/server/remoteExtensionHostProcess.js:94:160087)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async y.readText (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:9:315784)
	at async p.doesFileNeedToBeFixed (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:823850)
	at async /home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:822977
	at async Promise.all (index 0)
	at async p.getFilesToBeFixed (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:822923)
	at async p.updateTestSettings (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:822550)] {
  code: 'FileNotFound'
}
Starting Pylance language server.
Error 2021-09-08 15:22:34: Custom .env is likely not pointing to a valid file [EntryIsADirectory (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/src/self/110yards/api/.env' (Error: Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/src/self/110yards/api/.env' that is actually a directory)
	at _handleError (/home/mike/.vscode-server/bin/e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff/out/vs/server/remoteExtensionHostProcess.js:94:160293)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async y.readText (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:9:315784)
	at async h.parseFile (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:408867)
	at async m._getEnvironmentVariables (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:412149)
	at async m.getEnvironmentVariables (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:412047)
	at async u.create (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:92999)
	at async y.getCondaVersion (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:51657)] {
  code: 'FileIsADirectory'
}
Error 2021-09-08 15:22:34: Custom .env is likely not pointing to a valid file [EntryIsADirectory (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/src/self/110yards/api/.env' (Error: Unable to read file 'vscode-remote://wsl+ubuntu-20.04/home/mike/src/self/110yards/api/.env' that is actually a directory)
	at _handleError (/home/mike/.vscode-server/bin/e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff/out/vs/server/remoteExtensionHostProcess.js:94:160293)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async y.readText (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:9:315784)
	at async h.parseFile (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:408867)
	at async m._getEnvironmentVariables (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:412149)
	at async m.getEnvironmentVariables (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:412047)
	at async u.create (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:92999)
	at async S.create (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:94603)
	at async E.getActiveInterpreter (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:59:915819)
	at async Promise.all (index 1)
	at async f (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:417712)
	at async Object.t.sendStartupTelemetry (/home/mike/.vscode-server/extensions/ms-python.python-2021.9.1191016588/out/client/extension.js:78:418480)] {
  code: 'FileIsADirectory'
}
> conda --version

Code Snippet / Additional information

terminal

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kimadelinecommented, Sep 9, 2021

Yep it’s set to false by default (settings reference), so as long as you set it to true in your user settings you should be good to go 🙂

Closing as resolved.

1reaction
mdrydencommented, Sep 8, 2021

@karthiknadig good to know, thanks.

For what it’s worth, renaming the venv is not the root cause here, only something I tried as a resolution.

I’ve been able to recreate this issue with all of my python projects, all using their own newly created venv folders.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Can't "activate" virtualenv - Stack Overflow
Solution of the problem of virtual environment created but not activated. to make activate just add a space between .
Read more >
Terminal pane starts up before Python extension and virtual ...
The virtual environment is not activated, because the Python extension hasn't initialised. I checked my settings, and I see. "terminal.
Read more >
venv — Creation of virtual environments — Python 3.11.1 ...
When a virtual environment has been activated, the VIRTUAL_ENV environment variable is set to the path of the environment. Since explicitly activating a...
Read more >
Activating a virtual environment | Python Automation Cookbook
Go to the main directory that contains the project: $ cd my-directory · Type the following command: $ python3 -m venv .venv ·...
Read more >
Virtualenv and venv: Python virtual environments explained
Many Python IDEs automatically detect and activate a virtual environment if one is found in the current project directory. Microsoft Visual ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found