relative-import Questions
2
Solved
I've read quite a bit about relative import's tricky aspects (especially this question). However, the following example is still not working.
I have the following project (available on GitHub):
He...
Ancillary asked 15/1, 2024 at 22:16
14
Solved
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...
Guilford asked 3/1, 2013 at 3:50
3
Solved
I want to import a module from a subpackage so I went here Relative importing modules from parent folder subfolder and since it was not working I read all the literature here on stack and found a s...
Carroty asked 18/10, 2023 at 13:34
19
Solved
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 ...
Setser asked 2/5, 2017 at 0:40
13
Solved
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 ...
Withy asked 27/12, 2015 at 7:14
4
My folder structure is as follows
./fff
├── __init__.py
├── fg
│ ├── __init__.py
│ └── settings
│ ├── __init__.py
│ └── settings.py
└── obng
└── test.py
I want to import the settings.py i...
Teets asked 8/7, 2021 at 11:12
1
Solved
I have the following package structure (drastically simplified from a real use case):
mypackage/
├── __init__.py
├── mod1.py
│ ├── def func1(): return 1
│ └── ...
│
├── mod2.py
│ ├── def func...
Destination asked 21/8, 2022 at 18:52
4
Solved
Let's say I have the following structure:
dir_1
├── functions.py
└── dir_2
└── code.ipynb
In, code.ipynb, I simply want to access a function inside functions.py and tried this:
from ..funct...
Superheat asked 6/4, 2020 at 11:32
2
Solved
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 th...
Emmy asked 27/8, 2021 at 23:12
1
I have been trying for a couple of days to solve the relative import error in my project with no success.
I have the following project tree:
proj
|
|---__init__.py
|
|---lib
| |---__init__.py
| |--...
Grundyism asked 13/8, 2021 at 9:14
2
Solved
Here is my folder structure:
Mopy/ # no init.py !
bash/
__init__.py
bash.py # <--- Edit: yep there is such a module too
bass.py
bosh/
__init__.py # contains from .. import bass
bsa_files...
Haemostasis asked 13/10, 2016 at 13:21
1
Solved
In PEP 366 - Main module explicit relative imports which introduced the module-scope variable __package__ to allow explicit relative imports in submodules, there is the following excerpt:
When the...
Repetitive asked 15/9, 2020 at 20:14
3
Whenever you use autoimport provided by PyCharm it generates an absolute path import. i.e.
from my_package.my_subpackage import my_thing
instead of
from .my_subpackage import my_thing
Is ther...
Michaelson asked 9/2, 2018 at 9:24
2
Solved
I'm working on a Python application consisting of a core and multiple independent modules using the core. I'm having difficulty setting up relative imports of packages.
app
|- __init__.py
|- cor...
Sawyor asked 7/4, 2012 at 22:50
1
Solved
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_...
Smothers asked 24/4, 2016 at 17:55
1
Solved
I was trying to generate an executable for a simple Python script. My setup.py code looks like this:
from distutils.core import setup
import py2exe
setup(console=["script.py"])
However, I am get...
Examinee asked 6/1, 2016 at 12:11
1
Solved
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 ...
Cyclonite asked 8/7, 2014 at 0:37
1
Solved
So I'm using a template set by a co-worker and as a newbie to python I may be missing something very obvious.
The main directory has the init file which has a module I need for the main python fil...
Unbent asked 8/4, 2014 at 16:16
1
© 2022 - 2025 — McMap. All rights reserved.