6,061 questions
-2
votes
1
answer
78
views
Is it possible to install submodules of a python package dynamically?
I have a very complex Python library that is used by several people/projects for different purposes.
The structure is basically the same as many Python libraries, but I would like to give the ability ...
0
votes
0
answers
88
views
Setuptools : why editable mode does not work outside of my project directory?
I don't manage to make the editable mode pip install -e . for a local installation of my project. After the installation, when I import a constructor from a module of my package within in python shell ...
0
votes
2
answers
155
views
One liner for printing python's path [duplicate]
I am trying to put in my Bash script a one-liner that would print my python's path
python -c 'import sys; for p in sys.path: print(p)'
the for keyword is flagged as an invalid syntax
I was expecting ...
1
vote
2
answers
93
views
how to import module with TYPE_CHECKING as true
I want to generate a schema based on a class defined in another file, so i need to know the return type of these functions. However, the annotation might be based on some imports under TYPE_CHECKING.
...
-3
votes
1
answer
75
views
Importing some symbol from a Python script into its test script
I've got the following project tree:
SomeDir
|- script.py
|- TestDir
| |- test.py
script.py is designed to be called in CLI and contains several classes: notably one that does the actual job and one ...
6
votes
1
answer
213
views
Is there a short way to write "import" and "from import" for the same module?
I find myself mixing both import x and from x import y forms for the same module, depending how often a particular object is used and whether it is clear which modules it comes from.
For example I ...
2
votes
1
answer
98
views
My privately developed and installed module gives "ModuleNotFoundError: No module named 'jbpy'" at import
I'm implementing my own Python module package, called jbpy. I'm using setuptools with a pyproject.toml file as the build system.
I'm working on Ubuntu 24.04, but I also get the error under WSL on a ...
1
vote
0
answers
77
views
How is import os.path possible? [duplicate]
Since os is a module instead of a package, import os.path should fail. For comparison:
>>> import os.sys
Traceback (most recent call last):
File "<python-input-0>", line 1, ...
0
votes
1
answer
74
views
Use importlib.resources for files inside the top level parent module
I want to load a file from my python module using importlib.resources (see also this question).
If the file is inside a submodule, this is straight forward (run using python -m, see here):
import ...
1
vote
2
answers
83
views
Handling Missing Dependencies Gracefully in Python Modules
I'm currently working on a modular python framework. The current dilemma is, that one module has a set of submodules that have vastly different dependencies, and a user usually would only use one of ...
0
votes
1
answer
98
views
Build python project with custom packages using pyinstaller
How to build a python project into a single executable if it has files split in multiple directories?
This is my project structure:
├── main.py
├── main.spec
├── src/
│ ├── GUI/
│ │ ├── ...
0
votes
0
answers
29
views
How to manage internal dependencies within a project when using `pip install -e .`?
Detail of the Problem:
My simple project structure is as follows:
└─mris
├─mris.egg-info
├─seggms
│ ├─training
│ │ └─run_training.py
├─utilities
│ └─config.py (contains ...
0
votes
0
answers
70
views
Nuitka onefile can't find directory for dynamic extension loading
I'm working on a Pycord bot project, and I'm using Nuitka to compile it. My goal is to compile the main script as a single file (--onefile) for distribution, but still be able to dynamically load ...
2
votes
1
answer
79
views
Changing a variable in another file, with a function in that file
I have two files. file1 and file2.
file1:
color = (0, 0, 0)
class drawing:
def changeColor(newColor):
global color
color = (newColor)
def drawCircle(x, y, r, c=color)
#...
0
votes
0
answers
45
views
Using a folder named collections where I defined my own modules causes ModuleNotFoundError
I created a folder named collections, inside I defined some collections-related modules. When I went to used them, I got an ModuleNotFoundError.
Changing the name of collections to my_collections ...