From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0MwREH3hu18cSAAA0tVLHw (envelope-from ) for ; Mon, 23 Nov 2020 16:21:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id WNACDH3hu1/OJgAA1q6Kng (envelope-from ) for ; Mon, 23 Nov 2020 16:21:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D3CED9404E5 for ; Mon, 23 Nov 2020 16:21:16 +0000 (UTC) Received: from localhost ([::1]:38746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khEaZ-0007bm-PS for larch@yhetil.org; Mon, 23 Nov 2020 11:21:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khEZW-0007bU-IV for emacs-orgmode@gnu.org; Mon, 23 Nov 2020 11:20:10 -0500 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:42771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khEZT-0003bU-Nl for emacs-orgmode@gnu.org; Mon, 23 Nov 2020 11:20:10 -0500 Received: by mail-pg1-x535.google.com with SMTP id w16so2328482pga.9 for ; Mon, 23 Nov 2020 08:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=QUqfHwokAERh9AonHbof383NDdZeJbzu8ofV+aaaIWk=; b=DFRlYOgO4Pg1TMEvsX7uxHidbZJwTGvv+HOo/blAZM+WS3JwHkgW+ou4oh5kMu0tje 3x1nKJbHfDileGfHkMqm00d60/He8S00Znp53nVUcGQzhfO7SicxrPw2dLSCqnjeYF7E MH/5iUjY/lreckFOq+Z8U9eiojTxoglIgyX2NuhBQERjR+jC2rZPE3MzLbVJcPaV+jIH xKwgyWlq/VggqigCLoq/DxNR4/Trjf2Dja3YAsZGK9zPsjBAhZwmjDeDB0B5IJa6XDvK 7qVLyqqXiYSnCSdOf2YpETbCHIq7JTRRiQj+tJbM27/Z/AGtpPLUvWCNLOyDw2xNZ81h Thyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=QUqfHwokAERh9AonHbof383NDdZeJbzu8ofV+aaaIWk=; b=XS8BMNuLzu5/PKSQN2pUIPmBIIVnq9jJNZVM8nHwn7KoJbWm+enQB5cC1aYALBoeTG 1kJz5kTtNvyViRkMHvBnM2U61vuJVEeXjI3CT46kdvi5DS1tN8bBwgl9RO4niJE6K89h N3HUcGpVSZEkcTszHgMYMgPw2y03gBxaf4EDbDTTNEMOIwUBcgiytX+FAFcxLIC1EpGi rwIVVYS0VlmN64ymi8/JSWIO5YIjEwTtCXcmd0dlxQBi4N/f9sjImXzrKjSUCzdJ/IIn UKupoY0uetHSAKzw2b43xvTDCEPQr69xvhoGG+moQaKuDMjyFojPmv/QlhyTTwU5clsK N/1A== X-Gm-Message-State: AOAM5301P7I1nq85xWROBJogXG88HiCdQKjfMv1qMFhPoJ67mJngJ25y CR9KiBPe9X6KUYe9hPnMAF8= X-Google-Smtp-Source: ABdhPJyVaIsFF+m5iXezkAN6f8UeM4HObOznPKhtOV40QlXZSvIL0EzM3NqAU2xGDaF6cMwXzF+n8Q== X-Received: by 2002:a63:4c41:: with SMTP id m1mr170164pgl.427.1606148406034; Mon, 23 Nov 2020 08:20:06 -0800 (PST) Received: from localhost (199-83-220-90.PUBLIC.monkeybrains.net. [199.83.220.90]) by smtp.gmail.com with ESMTPSA id d3sm14781303pji.26.2020.11.23.08.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 08:20:05 -0800 (PST) From: Jack Kamm To: Joost Kremers , emacs-orgmode@gnu.org Subject: Re: ob-python: import local package into a session In-Reply-To: <87eekkt6s9.fsf@fastmail.fm> References: <87eekkt6s9.fsf@fastmail.fm> Date: Mon, 23 Nov 2020 08:20:04 -0800 Message-ID: <871rgkniyz.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=jackkamm@gmail.com; helo=mail-pg1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=DFRlYOgO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: AdfG8vCahD7y 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