6,058 questions
1 vote
0 answers
156 views
What is the documented behaviour (if any) when someone imports `pkg.__init__[ as pkg]` instead of `import pkg`?
To be clear, I'm not suggesting anyone actually should import pkg.__init__ directly. This is to understand potential pitfalls if someone decides to convert a module-only distribution into a package, ...
-2 votes
1 answer
86 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
2 answers
160 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 ...
-3 votes
1 answer
81 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 ...
2 votes
1 answer
104 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 ...
0 votes
1 answer
102 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 ...
0 votes
1 answer
129 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
86 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 ...