Using Visual Studio Code (VS Code) as an IDE with the Enthought Deployment Manager (EDM)

For context, please see Canopy GUI end of life -- transition to the Enthought Deployment Manager (EDM) and Visual Studio Code

Install the Enthought Deployment Manager (EDM) 

Product info and download. This is Enthought's preferred tool for Python installation and package management. 

Install Microsoft's Visual Studio Code

Product info and download. This is Microsoft's free, open-source, extensible, multi-platform IDE, not to be confused with Microsoft's commercial Visual Studio.

Install Enthought Tools Extension for VS Code

From within VS Code, install Enthought Tools for VS Code (see documentation).  An easy way to do this is to go to the Marketplace tab in VS Code, type "enthought", then select and install the Enthought extension, or you can download the extension separately. It provides an easy interface for installing and working with Enthought Python environments.

After installation, the Enthought extension can be used by clicking on the Enthought icon in the VS Code left-side toolbar:

vscode-enthought-extension.png

You can quickly create a new Python environment by using Enthought's curated "GettingStarted" environment bundle, which is bundled with the extension:

vscode-enthought-extension2.png

 

To see all the Enthought extension commands, open VS Code's Command Palette (Ctrl (Cmd) + Shift + P), then type edm to filter the list. These commands can be invoked by clicking buttons on the UI, or directly from that list.

About Microsoft's Python Extension for VS Code 

The Enthought extension ensures that Microsoft's Python Extension for VS Code is also installed automatically, so you do not need to install Microsoft's extension yourself. 

This extension has many settings; most of these are personal preferences. Here are a few basics; we plan to add more suggestions in the future. 

To open settings.json, the easiest way is to type Ctrl-Shift-P (Cmd-Shift-P on Mac) and then type Open Settings (JSON) in the Command Palette that appears at the top of VS Code.

The following is a simple sample settings.json file for VS Code:

{
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Args": [
        "--max-line-length=120",
    ],
    "python.linting.pylintEnabled": false,
    "files.trimTrailingWhitespace": true,
    "[markdown]": {
        "files.trimTrailingWhitespace": false
    },
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "editor.rulers": [80, 120],
    "editor.hover.enabled": true,
}

 

Universal Ctags Recommendation

To make navigating through the code easier, we recommend that you install the Universal Ctags software. If Ctags is installed and available on the system path, the Python plugin will automatically use Ctags to generate the tags file needed to navigate through your code to class and function definitions. At least for Python, there is no need for a separate Ctags plugin.

For Windows users, get the latest compiled release from Universal Ctags. It will be a zip file that simply has to be unzipped into a directory. We recommend that you unzip it into your user Documents\ctags directory. Afterwards, make sure that this directory is listed in  your Windows environment variable PATH.

Installation notes for MacOS using brew can be found on Homebrew Tap for Universal Ctags.

Linux users will need to clone the Git repository and compile as documented on Universal Ctags.

To use Ctags, select a class or function name in your code, type Ctrl-T, and then select one of the definitions listed in the drop-down at the top of VS Code.

General Python Package Recommendations

The following command should be run for each EDM environment that will be used with VS Code, to install flake8:

edm install -e <environment-name> flake8

The flake8 package is a Python linter (syntax checker) that is known to VS Code; installing it will stop VS Code's reminders to select a linter. An added benefit is that linting code while editing is generally a good practice.

Other VS Code Extensions

There are very many VS Code extensions, with overlapping functionalities. Here are some Python-specific extensions which you might consider:

autoDocstring
Bracket Pair Colorizer 2
CobiSymbolOutline
Language-Cython
Markdown All in One
Projects+
reStructuredText
Rewrap
Settings Sync

 

Please do not enter support requests in article comments

Please use article comments for suggestions to improve the article. For individual support requests, please follow these guidelines.

Have more questions? Submit a request

Comments

Powered by Zendesk