FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Unable to import module · Issue #299 · extrabacon/python-shell · GitHub

Repository navigation

Unable to import module #299

Description

The Question:
Hi,

I'm trying out python-shell in a next.js project and I wasn't able to import my local python module in the script.

const messages = await PythonShell.runString(`from example_module import a, b, c`);

I'm using a pyproject.toml at the project root to define the local module:

[tool.poetry]
packages = [{include = "example_module", from = "python"}]

[tool.poetry.dependencies]
python = ">=3.11,<3.13"
bayesian = {path = "./python/example_module", develop = true }

This is the error I'm seeing.

- error TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of PythonShellError
    at new NodeError (node:internal/errors:399:5)
    at Function.byteLength (node:buffer:793:11)
    at apiRes.end 
    at handler 
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  digest: undefined
}
PythonShellError: ModuleNotFoundError: No module named 'example_module'
    at PythonShell.parseError
    at terminateIfNeeded
    at ChildProcess.<anonymous>
    at ChildProcess.emit
    at ChildProcess._handle.onexit
    ----- Python Traceback -----
    File "/var/folders/rn/fvrs2khs7hq_hb99d7sqj_0h0000gn/T/pythonShellFile5599925788.py", line 2, in <module>
      from example_module import a, b, c{
  traceback: 'Traceback (most recent call last):\n' +
    '  File "/var/folders/rn/fvrs2khs7hq_hb99d7sqj_0h0000gn/T/pythonShellFile5599925788.py", line 2, in <module>\n' +
    '    from example_module import a, b, c\n' +
    "ModuleNotFoundError: No module named 'example_module'\n",
  executable: 'python3',
  options: null,
  script: '/var/folders/rn/fvrs2khs7hq_hb99d7sqj_0h0000gn/T/pythonShellFile5599925788.py',
  args: null,
  exitCode: 1,
  logs: []
}

Any suggestion is appreciated. Thank you so much.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL