High Level problem
I experiment with/test the Python code I am writing in “playground scripts”.
Usually I don’t keep these playground scripts around, but recently I have been finding some value in saving them for longer term use. So I decided to create a separate
Problem Setup
I have a conda environment active myproject
.
My working folder looks like:
~/x
__init__.py
something.py
~/x/playground
playscript.py
I would like to import something.py
in playscript.py
. I run playscript.py
as an interactive window using Jupyter.
If I try to relative import something.py
, that fails with:
{
"name": "ImportError",
"message": "attempted relative import with no known parent package",
"stack": "---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
File ~/x/playground/playscript.py:1
----> 1 from .. import something
ImportError: attempted relative import with no known parent package"
}
conda develop
(as of 2024 JUN) is not a solution: Deprecate or remove conda develop. Reading through that, multiple people seem to suggest:
pip install --no-build-isolation --no-deps -e .
Questions
Suppose I make changes to ~/x/something.py
, or add entirely new modules…do I need to pip install --no-build-isolation --no-deps -e .
again? If so, then this is not a good solution.
Related issues
See also the related: “develop” mode? #695
The relevant flag on the pip
command suggested is -e
: /a/35064498/3486684