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

2020-11-25 Thread Joost Kremers
On Tue, Nov 24 2020, Jack Kamm wrote: > If you install the package using either "python setup.py develop", or > "pip install -e", then Python will install your code via symlinks > instead of copying, so then you don't have to worry about reinstalling > every time you make an edit. Hey, that's

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

2020-11-24 Thread Tom Gillespie
I have also been dissatisfied with the current options for making local python libraries accessible in certain org files. The amount of setup that is required outside the org file itself was too large, especially if you want someone else who is not intimately familiar with python to be able to use

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

2020-11-24 Thread Jack Kamm
Joost Kremers writes: > I haven't really considered the option to install the utility functions as a > package in the virtual environment, because I expect to change and develop > those > functions together with the rest of the project. If it were a separate > package, > I'd need to reinstall

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

2020-11-24 Thread Joost Kremers
On Tue, Nov 24 2020, Maxim Nikulin wrote: > 2. It seems that *recommended* and more flexible way is per-project > (per-version) virtual environments: venv in python3, similar thing were > called virtualenv in python2: > https://docs.python.org/3/tutorial/venv.html Maybe there is a convenient

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

2020-11-24 Thread Maxim Nikulin
2020-11-23 Joost Kremers wrote: I can include packages installed in `site-packages` and have them available in all code blocks. But is there a way to import my own packages into a session? In particular, packages I haven't installed system-wide? I do not have a recipe ready for using with org

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

2020-11-23 Thread Joost Kremers
Hi Jack, On Mon, Nov 23 2020, Jack Kamm wrote: > 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. It all seems to depend on the exact directories, though, and other than modifying

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

2020-11-23 Thread Jack Kamm
Jack Kamm writes: > 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. Sorry, this was incorrect, you need to set PYTHONPATH

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

2020-11-23 Thread Jack Kamm
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

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

2020-11-23 Thread John Kitchin
I usually do that by either having the py file in the working directory of the session, in which case you simply import it. Alternatively something like this in python: import sys sys.path.insert(0, '/path/to/dir/with/myfile.py') import myfile you could also append to sys.path if that matters.

ob-python: import local package into a session

2020-11-23 Thread Joost Kremers
Hi all, If I have an Org file with Python source blocks, I can run them in a session with the `:session` header arg. That way, I can include packages installed in `site-packages` and have them available in all code blocks. But is there a way to import my own packages into a session? In