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.

virtualenv created in hidden directory (.venv/) is not automatically detected

See original GitHub issue

Issue Type: Bug

Behaviour

Expected vs. Actual

When a new virtualenv was created in the terminal, vscode used to popup a prompt to select it as the python interpreter

Steps to reproduce:

  1. Open a terminal within vscode
  2. python -m venv .venv

No popup.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Pyenv
  • Value of the python.languageServer setting: Pylance
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: true
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "autopep8"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: false
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: ["pythonDiscoveryModule"]
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.0.1786462952 VS Code version: Code 1.64.0 (5554b12acf27056905806867f251c859323ff7e9, 2022-02-03T04:20:17.224Z) OS version: Darwin x64 21.3.0 Restricted Mode: No

System Info
Item Value
CPUs Intel® Core™ i7-9750H CPU @ 2.60GHz (12 x 2600)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 7, 7, 7
Memory (System) 16.00GB (0.03GB free)
Process Argv –crash-reporter-id e58e3d2a-e26d-42be-b0a2-cfd7504cefbc
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30425749
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30433059
pythonvs932:30410667
wslgetstartedc:30426334
vscop453:30404998
vsrem710cf:30416617

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
tekumaracommented, Apr 19, 2022

@karrtikr ah good catch, that was it! I have

  "files.watcherExclude": {
    "**/.venv": true
  },

If I remove that, the virtualenv is found.

The reason I added the exclude was when I connect to a remote Linux instance I was getting errors about indexing taking too long. I guess what would be ideal is detection of .venv being created, but not watching of the individual files.

Is it still worth me trying the new insiders version?

1reaction
tekumaracommented, Feb 23, 2022

This is what I see when doing Python: Select Interpreter -> .venv

Python interpreter path: ./.venv/bin/python
> ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/linter.py -m flake8 ./sdt/main.py
cwd: .
> . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/printEnvVariables.py
> . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/printEnvVariables.py
> ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
cwd: .
##########Linting Output - flake8##########

0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code does not detect Virtual Environments
Activate your virtualenv. Go to the parent folder where your Virtual Environment is located and run venv\scripts\activate .
Read more >
Pycharm Terminal fails to activate virtual env
When I click Terminal, it does not activate the virtualenv environment. How to recreate: I create a new project, selecting the option to......
Read more >
Trying to come up with a default directory name for virtual ...
E.g. `python -m venv .venv` would have `.venv` as the directory ... It's hidden by default as it's almost an implementation detail and...
Read more >
Python Virtual Environments: A Primer
Decide Where to Create Your Environment Folders; Treat Them as Disposables ... (venv) PS> python -m pip install <package-name>.
Read more >
Python Tools for Managing Virtual Environments
To create a virtual environment in the directory .venv , try the following: ... The virtualenv tool is very similar to python -m...
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