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 / python settings are ignored

See original GitHub issue

Summary

On my macOS I’m trying to keep things tidy. That is the reason why I installed virtualenv and virtualenvwrapper. Python is installed via brew.

There is some configuration in VSCode to select Python’s virtualenv in the settings.json:

"python.venvFolders": [
        "~/.virtualenvs"
    ],

This works perfectly fine and the information (Python-version & selected virtualenv) is shown in the statusbar, but only if there’s some different filetype than Ansible is selected or the Ansible-extension is uninstalled or disabled.

With active Ansible-extension the virtualenv-Configuration is completely ignored and I get (of course) errors like these:

Ansible-lint is not available. Kindly check the path or disable validation using ansible-lint

This is my statusbar with any other file but “Ansible”: vscode-settings-file

This is my statusbar with a file of the type “Ansible”: ansible-file

Additionally / of course none of the other interesting features of the Extension “Ansible” is working:

  • autocompletion does not work
  • linting does not work

Extension version

v1.0.90

VS Code version

1.72.2

Ansible Version

ansible --version    
ansible [core 2.13.5]
  config file = None
  configured module search path = ['/Users/ppu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/ppu/.virtualenvs/ansible-runner/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/ppu/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/ppu/.virtualenvs/ansible-runner/bin/ansible
  python version = 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]
  jinja version = 3.1.2
  libyaml = True

OS / Environment

macOS 12.6, M1 ansible-lint --version
ansible-lint 6.8.2 using ansible 2.13.5

Relevant log output

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ppuschmanncommented, Oct 20, 2022

So I’m now using

    "ansible.python.interpreterPath": "/opt/homebrew/Cellar/python@3.10/3.10.8/bin",
    "ansible.python.activationScript": "~/.virtualenvs/ansible-runner/bin/activate",
    "python.venvFolders": [
        "~/.virtualenvs"
    ],

and it works: ansible-file-2

I still have to say, I don’t like it that much, because I now have to use configuration pointing to distinct Python versions in VSCode.

1reaction
ppuschmanncommented, Oct 21, 2022

@robinmalik I’d guess this issue is different than my initial issue since you’re apparently not using virtualenv but using Ansible in some container.

@yaegassy I still think the configuration with virtualenv and Python-Interpreter-Path could be more smooth, but I’d also be fine with closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Virtual Environment Being Ignored or Overridden
I have been having an issue where pip and python seem to be ignoring the fact that they are in a virtualenv. I...
Read more >
venv — Creation of virtual environments — Python 3.11.1 ...
A virtual environment is created on top of an existing Python installation, known as the virtual environment's “base” Python, and may optionally be...
Read more >
Python Virtual Environments: A Primer
In this tutorial, you'll learn how to work with Python's venv module to create and manage separate virtual environments for your Python ......
Read more >
Configure a virtual environment | PyCharm Documentation
Create a virtualenv environment · Do one of the following: · Select Add Local Interpreter. · In the left-hand pane of the Add...
Read more >
Configuration - tox
Skipped environments will be logged at level two verbosity level. ... tox allows setting the Python version for an environment via the ...
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