Python3

About

Python is a programming language that lets you work more quickly and integrate your systems more effectively.

Installation

Change enable from False to True in the python3 section (cf module installation).

vscode-anywhere:
    python3:
        enabled: True

You can also take a look at the VSCode-Anywhere python3 module configuration.

For more details read the official documentation.

Requirements

No requirements.

VSCode

Additionnal informations

Please read the environment documentation.

By default, the Python extension looks for and loads a file named .env in the current workspace folder, then applies those definitions. The file is identified by the default entry "python.envFile": "${workspaceFolder}/.env.

And you can also interact with your environment with the VSCode settings .vscode/settings.json:

  • python.envFile: Absolute path to a file containing environment variable definitions

  • python.venvPath: Path to the folder with a list of Virtual Environments

  • python.venvFolders: Folders in your home directory to look into for virtual environments (supports pyenv, direnv and virtualenvwrapper by default)

And also use environment variable (you can set these variables directly in your python.envFile:

  • WORKON_HOME: used by virtualenvwrapper and pipenv

  • PYTHONPATH: specifies additional locations where the Python interpreter should look for modules

virtualenv

If you want to test directly your virtualenv without configuring your settings:

cd <path_to_your_project>
. <installation_directory>\tools\env.ps1
.\<env>\bin\activate
VSCode-Anywhere .

After that you must select the good python interpreter. Press F1 and type:

> Python Select Interpreter

And select the right interpreter (virtualenv) from the list provided.

pipenv

If you want to test directly your pipenv without configuring your settings:

cd <path_to_your_project>
. C:\VSCode-Anywhere\tools\env.ps1
pipenv shell
VSCode-Anywhere .

After that you must select the good python interpreter. Press F1 and type:

> Python Select Interpreter

And select the right interpreter from the list provided.

poetry

If you want to test directly your poetry without configuring your settings:

cd <path_to_your_project>
. C:\VSCode-Anywhere\tools\env.ps1
poetry shell
VSCode-Anywhere .

After that you must select the good python interpreter. Press F1 and type:

> Python Select Interpreter

And select the right interpreter from the list provided.

anaconda

Please read the specific settings at the bottom of the page.

VSCode extensions

ms-python.python

This extension provides a rich support for the Python language (for all actively supported versions of the language: 2.7, >=3.5), including features such as IntelliSense, linting, debugging, code navigation, code formatting, Jupyter notebook support, refactoring, variable explorer, test explorer, snippets, and more!

VisualStudioExptTeam.vscodeintellicode

This extension provides AI-assisted development features for Python.

With the windows_portable profile this extension will not be installed.

ms-python.vscode-pylance

Pylance is an extension that works alongside Python in Visual Studio Code to provide performant language support. Under the hood, Pylance is powered by Pyright, Microsoft's static type checking tool. Using Pyright, Pylance has the ability to supercharge your Python IntelliSense experience with rich type information, helping you write better code faster.

kevinrose.vsc-python-indent

This extension corrects Python indentation in Visual Studio Code.

littlefoxteam.vscode-python-test-adapter

This extension allows you to run your Python Unittest or Pytest.

VSCode-Anywhere installs python modules nose, pytest and configurepytestto the default test adapter. unittest is a builtin python module.

VSCode settings

Global settings

{
  "python.analysis.typeCheckingMode": "basic",
  "python.languageServer": "Pylance",
  "python.testing.pytestEnabled": True,
  "code-runner.executorMap.python": "$pythonPath -u $fullFileName",
  "python.linting.pylintEnabled": False,
  "python.linting.flake8Enabled": True,
  "python.linting.flake8Args": [
    "--max-line-length=88"
  ],
  "python.linting.enabled": True,
  "python.autoComplete.addBrackets": True,
  "python.formatting.provider": "black",
  "dash.languageIdToDocsetMap.python": [
    "python3",
    "django",
    "twisted",
    "sphinx",
    "flask",
    "tornado",
    "sqlalchemy",
    "numpy",
    "scipy",
    "salt",
    "pandas",
    "matplotlib",
    "cvp"
  ]
}

Windows settings

{
    "python.workspaceSymbols.ctagsPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\scoop\\apps\\ctags\\current\\ctags.exe"
}

If anaconda is set to True:

{
    "python.condaPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\conda.exe",
    "python.pythonPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\python.exe",
    "python.formatting.blackPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\black.exe",
    "python.poetryPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\poetry.exe",
    "python.linting.flake8Path": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\flake8.exe",
    "python.testing.nosetestPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\nosetests.exe",
    "python.testing.pytestPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\pytest.exe",
    "python.pipenvPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\anaconda3\\current\\Scripts\\pipenv.exe"
}

Assuming you have installed in the default directory C:\VSCode-Anywhere.

If anaconda is set to False:

{
    "python.pythonPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\python.exe",,
    "python.formatting.blackPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\Scripts\\black.exe",
    "python.poetryPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\Scripts\\poetry.exe",
    "python.linting.flake8Path": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\Scripts\\flake8.exe",
    "python.testing.nosetestPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\Scripts\\nosetests.exe",
    "python.testing.pytestPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\Scripts\\pytest.exe",
    "python.pipenvPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\python\\current\\Scripts\\pipenv.exe"
}

Assuming you have installed in the default directory C:\VSCode-Anywhere.

If profile is set to windows_portable:

{
      "python.languageServer": "Jedi",
      "python.pythonPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\python3",
      "python.formatting.blackPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\black",
      "python.poetryPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\poetry",
      "python.pipenvPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\pipenv",
      "python.linting.flake8Path": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\flake8",
      "python.testing.nosetestPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\nose",
      "python.testing.pytestPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\usr\\bin\\pytest"
}

Assuming you have installed in the default directory C:\VSCode-Anywhere.

Linux Settings

{
    "python.workspaceSymbols.ctagsPath": "/home/linuxbrew/.linuxbrew/bin/ctags"
}

If anaconda is set to True:

{
    'pythonPath': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/python3',
    'autopep8Path': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/autopep8',
    'poetryPath': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/poetry',
    'flake8Path': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/flake8',
    'nosetestPath': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/nosetests',
    'pytestPath': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/pytest',
    'pipenvPath': '/home/linuxbrew/.linuxbrew/opt/anaconda3/bin/pipenv',
    'python.condaPath': '/home/linuxbrew/.linuxbrew/opt/anaconda3/conda'
}

If anaconda is set to False:

{
    'pythonPath': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/python3',
    'autopep8Path': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/autopep8',
    'poetryPath': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/poetry',
    'flake8Path': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/flake8',
    'nosetestPath': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/nosetests',
    'pytestPath': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.local/bin/pytest',
    'pipenvPath': '/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.local/bin/pipenv'
}

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

VSCode keybindings

No keybindings.

Software

Windows software

scoop

msys2

The following packages will be installed only if the profile is set to windows_portable profile:

Linux software

brew

  • anaconda3 (custom brew formulae only if anaconda is set to True)

Documentation

VSCode-Anywhere

Environment

Windows environment

PATH: C:\VSCode-Anywhere\apps\scoop\apps\python\current\Scripts

Assuming you have installed in the default directory C:\VSCode-Anywhere.

If anaconda is set to True:

PATH: C:\VSCode-Anywhere\apps\scoop\apps\python\current\Scripts;C:\VSCode-Anywhere\apps\anaconda3\current:C:\VSCode-Anywhere\apps\anaconda3\current\Library\mingw-64\bin:C:\VSCode-Anywhere\apps\anaconda3\current\Library\usr\bin::C:\VSCode-Anywhere\apps\anaconda3\current\Library\bin::C:\VSCode-Anywhere\apps\anaconda3\current\Library\Scripts

Assuming you have installed in the default directory C:\VSCode-Anywhere.

Linux environment

PATH: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.local/bin

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

If anaconda is set to True:

PATH: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.local/bin:/home/linuxbrew/.linuxbrew/opt/anaconda3/bin

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

Specific settings

anaconda

Allow to install anaconda:

vscode-anywhere:
  python3:
    enabled: True
    enaconda: True

Please read:

This is recommended method for the data sciences and with the use of Jupyter.

anaconda_update

Update all anaconda modules:

vscode-anywhere:
  python3:
    enabled: True
    enaconda: True
    enaconda_update: True

Requires that anaconda be set to True.

pip

Allow installing packages with pip.

  • pkgs: name of the packages to install

    • enabled: True to enable, False to skip (default to False)

    • version: the version of the pip package

  • opts

opts is not mandatory but allows to pass additional arguments.

Extra args can be arguments described in the Saltstack pip states or can be global Saltstack arguments.

Global opts packages settings:

  • pip:pkgs:opts:global: allow passing arguments to all pip packages when installing, updating, or uninstalling a package

  • pm:pkgs:opts:install: allow passing arguments to all pip packages when installing a package (cf states.pip.installed)

  • pip:pkgs:opts:update: allow passing arguments to all pip packages when updating a package (cf states.pip.installed)

  • pip:pkgs:opts:uninstall: allow passing arguments to all pip packages when uninstalling a package (cf states.pip.removed)

Specific opts packages settings:

  • pip:<mypkg>:opts:global: allow passing arguments to <mypkg> pip package when installing, updating, or uninstalling the package

  • pip:pkgs:<mypkg>:opts:install: allow passing arguments to <mypkg> pip packages when installing the package (cf states.pip.installed)

  • pip:pkgs:<mypkg>:opts:update: allow passing arguments to <mypkg> pip packages when updating the package (cf states.pip.installed)

  • pip:pkgs:<mypkg>:opts:uninstall: allow passing arguments to all pip packages when uninstalling a package (cf states.pip.removed)

Replace <mypkg> by the name of the package to install.

  • global:

vscode-anywhere:
  python3:
    enabled: True
      pip:
        opts:
          install:
            upgrade: False
          update:
            upgrade: True
          uninstall: {}
        pkgs:
          rope:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          flake8:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          black:
            enabled: True
            version: '>= 19.10b0'
            opts:
              install: {}
              update: {}
              uninstall: {}
          ptvsd:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          nose:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          pytest:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          pytest-xdist:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          poetry:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
          pipenv:
            enabled: True
            version: null
            opts:
              install: {}
              update: {}
              uninstall: {}
    
  • Windows:

If anaconda is set to True:

vscode-anywhere:
  python3:
    enabled: True
    pip:
      opts:
        global:
          bin_env: C:\VSCode-Anywhere\apps\scoop\apps\python\current\Scripts\pip.exe

Assuming you have installed in the default directory C:\VSCode-Anywhere.

If anaconda is set to False:

vscode-anywhere:
  python3:
    enabled: True
    pip:
      opts:
        global:
          bin_env: C:\VSCode-Anywhere\apps\scoop\apps\anaconda3\current\Scripts\pip.exe

Assuming you have installed in the default directory C:\VSCode-Anywhere.

If profile is set to windows_portable:

vscode-anywhere:
  python3:
    enabled: True
    pip:
      opts:
        global:
          bin_env: C:\VSCode-Anywhere\apps\scoop\apps\msys2\current\usr\bin\pip3

Assuming you have installed in the default directory C:\VSCode-Anywhere.

  • Linux:

vscode-anywhere:
  python3:
    enabled: True
    pip:
      pkgs:
        setuptools:
          enabled: True
          version: null
          opts:
            install: {}
            update: {}
            uninstall: {}
        rope:
          enabled: False
        flake8:
          enabled: False
        autopep8:
          enabled: False
        nose:
          enabled: False
        peotry:
          enabled: False

If anaconda is set to True:

vscode-anywhere:
  python3:
    enabled: True
    pip:
      opts:
        global:
          bin_env: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/home/.nix-profile/bin/pip2
          env_vars:
            PYTHONPATH: ''
          target: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/python3

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

If anaconda is set to False:

vscode-anywhere:
  python3:
    enabled: True
    pip:
      opts:
        global:
          bin_env: /home/linuxbrew/.linuxbrew/opt/anaconda3/bin/pip

Last updated