Offline use of Visual Studio Code
For the past few years, I've been doing most of my coding in "the Scientific Python Stack (NumPy, SciPy, Matplotlib, ...), and friends. I still use MATLAB and Mathematica where there are gaps in functionality or the numerics in NumPy/SciPy are not up to snuff. I used to use Spyder, the IDE included with Anaconda Python, but over the last couple of years have switched to Visual Studio Code for both an IDE and Jupyter notebooks. I'm not alone; VSCode has dominated the Stack Overflow IDE Survey for several years.
One of the main features of VSCode is the rich ecosystem of extensions. When you're online, installing or updating an extension is a couple of mouse clicks; the procedure for offline use isn't so refined and has changed over time.
If you're starting fresh, VSCode supports a "Portable Mode", documented here:
"This mode enables all data created and maintained by VS Code to live near itself, so it can be moved around across environments." The implication is that you have one "primary" computer that is online and then mirror the extensions and other data to your other installations. My life isn't that neat.
The other mode is to manually download the ".vsix" files and then load them in your off-line installation. Microsoft doesn't document this process succinctly, so here it is:
- Go to the Visual Studio Code Marketplace: https://marketplace.visualstudio.com/
- Find the extensions you want. For example, for Python I search on "microsoft python". I add "microsoft" because I prefer not to use third-party extensions, as MS does not have a very robust vetting procedure and they might contain malicious code.
- Select each extension. The last item in the Resources section of the sidebar on the right is "Download Extension".
- Down load the extension. In some cases, you'll be presented with a dropdown menu of OS/architecture choices. Pick and download the one(s) corresponding to your offline machine(s).
- Lather, rinse, repeat
- Move the collection of ".vsix" files to your offline computer... memory stick, CDR, remote viewing...
- In your offline installation of VSCode, bring up the command palette (Command-Shift-P on a Mac), and enter "VSIX" and select "Extensions: Install from VSIX..." . Navigate to your collection of VSIX files, select the ones you want to install, and press "Install".
- Restart VSCode
- Start coding!
What complicates this is that some extensions, such as the Black Formatter, are simply interfaces to an external program that does the heavy lifting. The documentation for "pip download" is here
python -m pip download --only-binary=:all: --dest . --no-cache <package>"
is supposed to work but I find that you need to do the downloads on a machine with the same architecture, OS, and Python version as the offline target machine. Seems like an important missing piece in the whole Python ecosystem. Sigh.
Comments