简体   繁体   中英

Add Python packages as dependency when building a VS Code extension

I'm building a VS Code extension that assumes that the user already has a particular Python package installed on their system.

What could be the possible approaches to install that Python package to the user's machine when the user installs my VS Code extension.

I was able to think of a few ways to do so but couldn't find any resources on the internet validating my approaches:

  1. creating a subprocess from inside the VS Code extension and calling pip install if VS Code is allowed to make such a privileged install to the user's machine without having any special/admin rights?
  2. adding that package as a dependency in the package.json so it gets installed when the user tried to install the extension? Is there a way to add Python packages as dependencies?

This doesn't sound like a good idea, because different users will use different Python versions and python environments. When you specify a specific Python version, is the cost of using the extensions you designed a little too high?

Moreover, with the update of Python version, your extensions also need to design new specific dependent versions.

I suggest that you try to let users customize as vscode recognizes Python interpreter , otherwise the applicable population will not too much.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM