relative-import

Relative import – from from ZSSGAN.model.ZSSGAN import ZSSGAN

Relative import – from from ZSSGAN.model.ZSSGAN import ZSSGAN Question: I’m working on the StyleGAN-NADA repo, and I am having issues loading the ZSSGAN function. The command line to do so is from ZSSGAN.model.ZSSGAN import ZSSGAN, where The first ZSSGAN is the name of a folder model is a folder inside the first folder The second …

Total answers: 1

Python error – ImportError: attempted relative import with no known parent package

Python error – ImportError: attempted relative import with no known parent package Question: So, my files/folders structure is the following: project/ ├─ utils/ │ ├─ module.py ├─ server/ │ ├─ main.py Inside project/server/main.py I’m trying to import project/utils/module.py using this syntax: from ..utils.module import my_function. I’m using VSCode, and it even autocomplete for me as …

Total answers: 2

Relative imports – ModuleNotFoundError: No module named x

Relative imports – ModuleNotFoundError: No module named x Question: This is the first time I’ve really sat down and tried python 3, and seem to be failing miserably. I have the following two files: test.py config.py config.py has a few functions defined in it as well as a few variables. I’ve stripped it down to …

Total answers: 18

Python relative-import script two levels up

Python relative-import script two levels up Question: I’ve been struggling with imports in my package for the last hour. I’ve got a directory structure like so: main_package | | __init__.py | folder_1 | | __init__.py | | folder_2 | | | __init__.py | | | script_a.py | | | script_b.py | | folder_3 | | …

Total answers: 1

Import local function from a module housed in another directory with relative imports in Jupyter Notebook using Python 3

Import local function from a module housed in another directory with relative imports in Jupyter Notebook using Python 3 Question: I have a directory structure similar to the following meta_project project1 __init__.py lib module.py __init__.py notebook_folder notebook.jpynb When working in notebook.jpynb if I try to use a relative import to access a function function() in …

Total answers: 12

Python importing a module from a parallel directory

Python importing a module from a parallel directory Question: How would I organize my python imports so that I can have a directory like this. project | | __init__.py | src | | __init__.py | classes.py | test __init__.py tests.py And then inside /project/test/tests.py be able to import classes.py I’ve got code looking like this …

Total answers: 1

Relative imports for the billionth time

Relative imports for the billionth time Question: I’ve been here: PEP 328 – Imports: Multi-Line and Absolute/Relative Modules, Packages Python packages: relative imports Python relative import example code does not work Relative imports in Python 2.5 Relative imports in Python Python: Disabling relative import and plenty of URLs that I did not copy, some on …

Total answers: 12