emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ob-python: import local package into a session


From: Jack Kamm
Subject: Re: ob-python: import local package into a session
Date: Mon, 23 Nov 2020 08:20:04 -0800

Hi Joost,

> What I'm trying to do is to import a Python file with a bunch of utility
> functions into the ob-python session. I thought this might be possible if I'd
> structure my code as a regular Python package, because that works if I want to
> import my utility functions into another Python file. But it doesn't seem to
> work for the ob-python session.

You need to make sure your module is either in the working directory you
started the Python session in, or in your PYTHONPATH, for example by
adjusting os.env["PYTHONPATH"] before attempting to import the module.

This shouldn't be ob-python or even Emacs specific. You can test whether
things work by typing "python" in the terminal and attempting to import
your module.

By the way, are you using IPython or vanilla Python? I recently
encountered an issue trying to import modules through a symlink in
IPython, whereas it worked perfectly fine in a vanilla Python session.

Jack



reply via email to

[Prev in Thread] Current Thread [Next in Thread]