bun_python icon indicating copy to clipboard operation
bun_python copied to clipboard

By default its not considering current working directory as source directory

Open rdev06 opened this issue 9 months ago • 0 comments

create a file foo.py

and define a function

def greet(name: str):
    return 'greet ' + name

then within js file

import { python } from "bun_python";

const foo = python.import('foo')
console.log(foo.greet('yourself'))

This will throw an error. I checked in sys.path, current working directory was not their. For now the only possible way to use this by a workaround like this

import { python } from "bun_python";

// +++++++manually add current working directory into sys path++++++
const sys = python.import('sys');
sys.path.append(__dirname);

const foo = python.import('foo')
console.log(foo.greet('yourself'))

rdev06 avatar Apr 11 '25 13:04 rdev06