Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
How to run this python file without using the command prompt (purely code)

I am trying to run a python file called testingFile.py inside a VS Code extension as shown below:

// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const { ChildProcess } = require('child_process');
const vscode = require('vscode');
const { exec } = require('node:child_process');

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed

/**
 * @param {vscode.ExtensionContext} context
 */
function activate(context) {

    
    let disposable = vscode.commands.registerCommand('fileDialog.openFile', function () {

        const options = {
            canSelectMany: false,
            openLabel: 'Open'
       };
        vscode.window.showOpenDialog(options).then(fileUri => {
            if (fileUri && fileUri[0]) {
                console.log('Selected file: ' + fileUri[0].fsPath);
            }
        });
    });

    context.subscriptions.push(disposable);
}

// this method is called when your extension is deactivated
function deactivate() {}

module.exports = {
    activate,
    deactivate
}

all this extension does is open a file dialog. when I would like to do is as follows: once I get the file path from the user, I want to trigger the execution of testingFile.py. please note that testingFile.py is located in the same location as extension.ts (the code seen above). I was initially trying to use spawn or exec. I am having a hard time getting them to work.

Perhaps it could also be run using vs code's built in commands such as vscode.commands.executeCommand('python.execInInterminal...)

but I cant quite figure out how it works.

Any advice would be greatly appreciated!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!