2,084 questions
2
votes
1
answer
60
views
Dynamically Loading Modules of the Same Name but Different Paths
I'm making a sort-of mod loader that automatically loads certain classes with a specific variable defined from any files in the root directories' mods folder.
My file structure is as follows:
mods
- ...
2
votes
1
answer
65
views
Python packaging: single-module with package data
I want to install my single file module together with its py.typed file using setuptools and pyproject.toml.
I'm packaging a Python single-module, and so far I was using a very simple pyproject.toml:
[...
0
votes
0
answers
73
views
Load Python module in Unbound DNS in Ubuntu 22.04
I have been trying to load Python module inside Unbound DNS. Following is the version list of the tools I am using:-
Python: 3.10.12
Ubuntu: 22.04
Unbound DNS: 1.23.0
The unbound.conf contains ...
0
votes
1
answer
43
views
ModuleNotFoundError: No module named 'Teacher' in Python when importing from another folder
ModuleNotFoundError: No module named 'Teacher' even though the file exists
I am trying to import a function from one Python file to another, but I keep getting the error:
ModuleNotFoundError: No ...
0
votes
0
answers
69
views
Import Helpers.py from different directory
I am making a React app.
I am using some Python code to automate a few things.
But currently I am duplicating some Python code across separate components. I would like to avoid this, and place all my ...
0
votes
1
answer
58
views
Python 3 relative imports behave differently between local run and on k8s
I have the following structure:
project/
|- src/
|- __init__.py
|- package/
|- __init__.py
|- module1.py
|- module2.py
Let's say module1.py ...
0
votes
1
answer
38
views
Not able to use Smartsheet python api when packaging project using Nuitka
I wrote a python project that automates tasks and makes use of the smartsheet api but when I package this project into an executable with nuitka I get the error:
ImportError! Could not load api or ...
-1
votes
1
answer
159
views
What is the best way to manually install a python library?
I am currently creating a python library, and I want to find what is the best way for a user to install it on their computer.
It is not distributed on Pypi (or Pypi test) for now, so I want them to ...
-1
votes
1
answer
48
views
ModuleNotFoundError when referencing folder in Python [duplicate]
I have a Python3 project arranged as follows:
C:\automation\framework\constants.py
C:\automation\tests\unit-tests\test_myunittest.py
In my unit test, I'm trying to call methods in framework folder, ...
0
votes
1
answer
33
views
Python3 importing enum from directory
I need to import enum class which sits in dir A from some other file which is in dir B.
So I have the following:
- enums
-- __init__.py
-- flavors.py
- setUp
-- test.py
flavors.py
from enum import ...
-1
votes
2
answers
68
views
Importing python function that lives in a sub-subfolder
The following directory structure:
repo/
├─ third_party/
│ ├─ project/
│ │ ├─ src/
│ │ │ ├─ moduledir/
│ │ │ │ ├─ __init__.py
│ │ │ │ ├─ main.py
├─ pythonscript.py
In main.py there's a (...
-2
votes
1
answer
48
views
Visual Studio Code is being really weird about python interpreters
I am trying to use the neat-python package. I had to install it directly from the github using pip install git+https://github.com/CodeReclaimers/neat-python.git because they haven't updated their pypi ...
0
votes
1
answer
102
views
I manually installed the Python docx library in my script folder but I can't import it?
For admin reasons I can't edit the PATH variable so I couldn't use pip to install my PyPi and 3rd party libraries/modules, so I worked around it and I installed their source code using the official ...
0
votes
1
answer
627
views
gspread API 502 Server Error when updating a Google Sheet with Python
I'm pretty new to this stuff, so I'm going to provide as much information as possible just in case it is relevant.
In VSCode (1.93.1), I created a Python script which makes updates to a Google Sheets ...
1
vote
3
answers
254
views
Python - import function from parallel directory
Let's assume I have two parallel directories, with simple python files.
'dir_one' with file_one.py
'dir_two' with file_two.py
In file_one.py there is a function named function_one.
How can I import ...
1
vote
1
answer
106
views
How to avoid the "Duplicate Module Import Trap" in python?
I recently encountered a perplexing issue regarding module imports in Python, particularly with the way instances of classes can be duplicated based on different import styles.
I had to fight to be ...
0
votes
1
answer
74
views
How to prevent `pip install` resulting in duplicate code?
I am working on a library with some others. Our git repo (called modulename) looks like this
modulename/
src_file_1.py
src_file_2.py
tests/
...
.../
The instructions are to clone this somewhere ...
0
votes
1
answer
536
views
Micropython on RP2040, ImportError: no module named 'lcd_module'
I am running MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040 and I'm trying to import a module that I have written (called lcd_module). However, I keep running into this import error.
...
0
votes
1
answer
43
views
I wrote the code for this analog clock, but I don't know why place of the numbers are not correct
import pygame
from math import radians, sin, cos
from datetime import datetime
class Clock:
def __init__(self):
self.width, self.height = 800, 800
self.white = (255, 255, 255)
...
3
votes
1
answer
1k
views
ModuleNotFoundError: No module named 'paramiko.auth_strategy' while using fab2 python
I'm trying to execute a python task using fab. I've installed fab2 for python3 and trying to use it to run the task in a venv. Unfortunately using fab2 keeps giving me this error:
(venv) My-MacBook-...
0
votes
0
answers
286
views
How to inspect Python file/module information without using `__file__` — perhaps in a module-level `__getattr__(…)` function?
I have a utility package for Python projects I maintain and use. It’s a bundle of lightweight, common, junk-drawer tools (e.g. command parsing, app lifecycle management, document generation, &c &...
0
votes
1
answer
51
views
Why is my Tkinter image failing to load / be retained when the active file is not __main__?
I am developing a Python application using Tkinter. I have created a module which is essentially a modal to be called elsewhere in the application - in the same file I check if name is main, and I ...
-3
votes
1
answer
96
views
python module install stuff
whenever i try to use python module install in the shell (im trying to use the command "python -m pip install pygame") and whenever i try to it says "Python was not found; run without ...
1
vote
2
answers
229
views
Use Pybind11 library created with MSYS2,CMake and Make in Python
I have just created a library with Pybind11 from the C++ side:
I did it with MSYS2 and CMake and Make. (I have GCC, Make, CMake and Pybind11 installed with the commands)
pacman -S mingw-w64-x86_64-gcc
...
0
votes
1
answer
152
views
Programming newbie - How can I fix an python import module error? [closed]
I'm using an old version of Python (v3.2) on a USB standalone environment (Portable Python) for simplicity and educational purposes since it works virtually on any computer without any software ...