python-shell
python-shell copied to clipboard
How do I use pipenv?
How do I run python with pipenv run python, instead of python? I've installed a module with pipenv, and now I need the script to import that module, but it can't be found.
Find the environment folder in your machine , something like
/Users/me/.local/share/virtualenvs/folder-name-C0HELq_u/bin/python3
And use it as pythonPath
I used
import { join } from "path";
PythonShell.defaultOptions = {
pythonPath: join(execSync("pipenv --venv").toString().trim(), "Scripts/python"),
};
which seems to work fine and doesn't require any hardcoding paths