2,083 questions
2
votes
1
answer
65
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
- ...
0
votes
0
answers
23
views
pyueye is_GetCameraList gives wrong dwCameraID
When I open "IDS Camera Manager", I can read all serial numbers, camera type and CameraID of the connected IDS cameras.
I guess that the same functionality expected for the pyueye.ueye....
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:
[...
2
votes
1
answer
108
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
0
answers
74
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
1
answer
50
views
Anaconda Python3 virtual environment unable to recognise local modules
I'm reproducing a project code and trying to execute it locally.
It uses Python 3.6 and old packages dating to 2017 and PIP struggles to install them and returned error codes which were 40 pages long.
...
0
votes
0
answers
70
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
78
views
Am I using a "backported module"?
I'm trying to use the Python vermin utility to determine the minimum version needed to run a script of mine. Running it, I get:
$ vermin --no-parse-comments foo.py
Tips:
- You're using potentially ...
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 ...
1
vote
2
answers
57
views
Executing & accessing python module code with __all__ in __init__.py
So I'm trying to write a simple wsgi python module where I use __init__.py to bring in variables & functions from another file but I can't seem to get the module to load. I keep getting the "...
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 ...
2
votes
3
answers
91
views
How to "fold" python files used as modules into the main script file?
Suppose I have two Python script files: foo and utils/bar.py in some directory. In foo, I have:
import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from utils.bar import ...
-1
votes
1
answer
161
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 ...
0
votes
1
answer
59
views
Docker python not able to recognize custom module
I have a project with the following structure:
project/
checks/
__init__.py
<some files here>
engine/
__init__.py
<some files here>
models/
__init__.py
<...
-1
votes
1
answer
49
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, ...
1
vote
1
answer
416
views
Troubleshooting consuming Python module in Azure function
I have the following code structure in my Python (3.12.3) application:
**ROOT**
-- .venv
-- azure_functions
---- function_app.py
---- host.json
---- local.settings.json
---- requirements.json
-- src
--...
0
votes
1
answer
37
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
vote
1
answer
76
views
How to create a module of constants accessible directly and through a dictionary
I want to create a module called 'constants.py' that contain all the constants specific to my system.
To offer flexibility I would like to be able to access the constants directly like this:
constants....
-1
votes
2
answers
69
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 (...
0
votes
1
answer
83
views
Constant error while referencing function in package (TypeError: 'module' object is not callable)
I get error while trying to execute pytest UTs for the project.
E TypeError: 'module' object is not callable
I have the following repository structure:
├───src
│ └───company
│ ├───acc
│ ...
-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
0
answers
49
views
Python modules inside subdirectories not found
I'm using Python 3.12.5 and my directory structure is as follows:
project/
--> subproject/
--> scripts/
--> script.py
--> utils/
--> __init__.py
...
0
votes
1
answer
110
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 ...
1
vote
1
answer
61
views
How to export module name to functions launched as a process?
I have two functions myFunc() and myOtherFunc() defined in two different files: generic.py and no_choice.py with two different implementations. I import them as follows into main.py:
main.py:
if ...
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 ...
-2
votes
1
answer
484
views
Unable to install modules in python 3.12.6 through command prompt
I have installed Python 3.12.6 with idle Python, Python, Python module docs.
All 64bit versions are in version 3.12 respectively but I can not seem to install modules.
I did this in the command prompt:...
1
vote
3
answers
258
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 ...
0
votes
1
answer
444
views
Installed Python module is not found in either IDLE and command prompt
I am trying to write a simple script that should include a library for working with PDFs that I found online called Camelot.
I installed it with pip and the module displays in the site-packages folder ...
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 ...
1
vote
3
answers
90
views
Vs-code unable to import modules modules load
I'm opening the same python project in pycharm and everything is working well
opening same folder on vs code with same interpreter
I'm getting error 'Unable to import' on local modules in the project
...
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
44
views
"Collecting" classes/variables from various files to simplify importing?
Suppose several classes are defined in multiple different files across a Python project, such as
mylib.somefile.Class1
mylib.somefile.Class2
mylib.anotherfile.Class3
mylib.athirdfile.Class4
...
What ...
0
votes
1
answer
546
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
42
views
ImportError and SyntaxError in Python Project Structure
Problem Description:
I am working on a Python project with the following structure:
Scriptus
├── frontend
│ ├── hf_call.py
│ ├── slide_deck.py
│ ├── slide_gen.py
│ └── ui.py
├── ...
0
votes
1
answer
50
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)
...
0
votes
1
answer
386
views
AttributeError: property 'mode' of 'JpegImageFile' object has no setter
I'm getting an error:
AttributeError: property 'mode' of 'JpegImageFile' object has no setter
While trying to open an image using the Pillow library.
My code:
from pil import Image as pl
my_img = pl....
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-...
2
votes
1
answer
2k
views
What is the difference between installing a module with pip/setup.py vs adding it to PYTHONPATH?
I have a custom Python module I want to use in another project. This module gets deployed to production as well. I have two options:
Add a setup.py and install the module locally with pip.
Add the ...
0
votes
0
answers
289
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
119
views
Does Zscaler has api endpoints to Backup configurations?
Does Zscaler has exposed api endpoints to backup configuration or any python library available to backup configuration settings ?
I have the documentation of common endpoints which zscaler has exposed ...
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 ...
2
votes
1
answer
87
views
Is it possible to use the same Django application name in multiple locations within a project?
I have a similar project structure to one below.
project_name/
│
├── apps/
│ ├── items/
│ │ ├── purchases/
│ │ │ ├── migrations/
│ │ │ ├── templates/
│ │ │ ├── __init__.py
│ │...
-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
85
views
Python issue with importing from submodule including scripts that also import from submodule?
My Python project has the following file structure.
module/
├── __init__.py
├── main.py
│
└── sub_module/
├── __init__.py
├── foo1.py
└── foo2.py
My goal is to import a class Bar from ...
1
vote
2
answers
230
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
2
answers
175
views
Importing a folder that has same name as a package
Let say I have a folder Pkg1, and a library also called Pkg1 (installed elsewhere) on the computer.
I also have a file run.py at Pkg1 > scripts > run.py.
I want to do:
from Pkg1 import Function1
...
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 ...
0
votes
2
answers
1k
views
Pyinstaller: Exe throws ModuleNotFoundError: No module named '...'
I'm a new programmer (6 month) and use this forum for the first time. So please allow me missing information and incorrect entries.
I wrote my own logging package, and like to import it into another ...
0
votes
1
answer
221
views
How to set up DJANGO_SETTINGS_MODULE with absolute path of the settings.py file
I need to write some scripts for django and trying to set up the DJANGO_SETTINGS_MODULE environment variable at the beginning of each script. The scripts, manage.py and myproject directory are in the ...