Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
65 views

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 - ...
Ice's user avatar
  • 21
0 votes
1 answer
105 views

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 ...
502E532E's user avatar
  • 581
0 votes
1 answer
63 views

inspect.getsource() and inspect.getsourcefile() can access source info for a function, but not for a class, when they are in a module that is imported dynamically with importlib. Here are two files, ...
Jason S's user avatar
  • 191k
1 vote
0 answers
90 views

I tend to alwasy run the testers from inside the module folder, but this breaks the "resources.files" functionality, as it seems not to be able to find the module any more module folder ...
hewi's user avatar
  • 1,446
0 votes
0 answers
100 views

I'm working on Alembic migration github action and need to import base metadata class inside python migration script which locates in another directory. I can't import it directly inside python ...
andrey's user avatar
  • 1,197
2 votes
1 answer
68 views

The document of Python's import system tells that there are 3 default finders/importers (built-in, frozen, and the import path one). But when trying to get the repr of sys.meta_path, I got another ...
Phuturesh's user avatar
0 votes
1 answer
91 views

If I have a venv path, how can I find out if a Python module is installed inside that venv? I normally use importlib.util.find_spec. But this only works for the current venv that is active and does ...
ArianNa's user avatar
  • 53
0 votes
1 answer
106 views

According to PEP420, namespace packages have the lowest precedence. For example, import xxx will not create a namespace package xxx if there are any xxx/__init__.pys or xxx.{py,pyc,so,pyd}s in any ...
John Ao's user avatar
  • 169
0 votes
1 answer
65 views

I am writing a small web app (https://github.com/r-owen/base_loom_server) and it runs on macOS and Raspberry Pi, but a Windows user reports an exception when Python reads a UTF-8-encoded resource file ...
Russell Owen's user avatar
0 votes
1 answer
52 views

I'v been struggling with importing a sub module. In main.py two modules are imported located under 220_04_070. I'm using importlib since the directory name only consist of numbers. common.py just ...
hzcodec's user avatar
  • 57
0 votes
2 answers
176 views

I am trying to dynamically import functions from a file in a subdirectory. For example: workspace --|main.py ----|subfolder1 ------|subfolder2 --------|file1.py --------|file2.py The file main.py ...
GalaxyGamerYT's user avatar
1 vote
0 answers
52 views

I am trying to setup Octoprint on a new orangepi 3b board. It has been a bit problematic. One problem is about access to gpio for all the existing plugins. The standard RPi.GPIO python library does ...
Lars's user avatar
  • 11
5 votes
2 answers
712 views

When I upgrade importlib_meta from version 8.4.0 to 8.5.0 (released just yesterday, Sep 11 2024), I get the following error when I start running the development server with python manage.py runserver: ...
Paul's user avatar
  • 116
1 vote
0 answers
1k views

When trying to reload the torch library in Python, by running the following lines of code, I encountered the error below: import torch import importlib importlib.reload(torch) ------------------------...
jmpion's user avatar
  • 11
0 votes
1 answer
89 views

I'm trying to run celery beat worker and a normal celery worker as docker containers. I have my tasks in flask application. The normal celery worker is working fine but getting following error in beat ...
Albin Antony's user avatar
0 votes
1 answer
64 views

TL;DR: How do I read a module's __all__ definition and dynamically add it to the package-level __init__.py without actually running any slow code in the module itself? I am writing a library and have ...
Yaseen's user avatar
  • 94
-1 votes
1 answer
68 views

I'm trying to reload from a python script a custom function because i'm editing the function constantly and i dont want to reload the kernel each time i make a change on the file. I have read that i ...
Simon's user avatar
  • 1,209
0 votes
2 answers
78 views

I've found that the snippet below when reloading a module test unexpectedly has all variables already defined in globals()/locals(). Why this happens? I've noticed this "xxx" in locals() ...
FamousSnake's user avatar
1 vote
0 answers
116 views

Is there a way to get the python package distribution (wheel) name for a given module (python object given by import ...)? I know that it's possible to get meta-information about installed packages ...
Philip Couling's user avatar
0 votes
1 answer
52 views

The code below is a utility I wrote that installs and restarts a script automatically without having the user need to parse through errors to install. Ideal usage would be below: #file1.py from file2 ...
Painguy's user avatar
  • 567
0 votes
2 answers
169 views

I know the usual Python import system, packages, __init__.py, the __import__ function (see In python, how to import filename starts with a number), etc. I know the classic How do I import other Python ...
Basj's user avatar
  • 47.5k
0 votes
0 answers
30 views

In one coding exercise in my Udemy course, a student is required to write a program that checks whether the total length of three strings read from the standard input is equal to 10, i.e. a one-liner ...
AlwaysLearning's user avatar
1 vote
1 answer
191 views

I'm working on a project where I need to override files located in the ./lib/python3.9/site-packages" directory. I have the following hook that does just that using importlib.util and sys....
Farooq Alaulddin's user avatar
0 votes
1 answer
817 views

I have multiple distributions that each provide a Python package of the same name (because they have the same API and same functionality, just different implementations). I want to be able to report ...
Sam Newbold's user avatar
0 votes
0 answers
301 views

I'm trying to install geopandas for use in a QGIS Plugin. create a venv install geopandas add site-packages to path import geopandas # sys.executable - path to qgis python interpreter # venv_path - ...
TheFunEmbargo's user avatar
1 vote
0 answers
604 views

I'm trying to figure out what the best practice is when it comes to reading data from within a package. I understood that in python 3.12 I should use importlib.resources, see e.g. How to read a (...
BdB's user avatar
  • 503
0 votes
0 answers
1k views

I'm working on some graphs using NetworkX using Spyder and I've encountered this error involving the importlib.resources. Here's my code. import networkx as nx from importlib import files # Create an ...
Kaixzer's user avatar
  • 21
0 votes
1 answer
890 views

I have an application that unfortunately does not support Python past 3.7. I have some code I'm trying to port (from Python 3.12) back to Python 3.7 that uses importlib.resources.files to get the path ...
Jason C's user avatar
  • 40.6k
0 votes
0 answers
49 views

I have a class that should dynamically import a module depending on a parameter passed to the class's constructor. I'm doing this by using a dictionary where the keys are the possible parameter values,...
kylemoely's user avatar
-2 votes
1 answer
73 views

I am attempting to import an object using importlib.import_module, but am getting a ModuleNotFoundError no matter what I try. I've read through as many related posts as I can find, but haven't been ...
Graham B's user avatar
1 vote
0 answers
110 views

I have json files which I would like to embed within my Python package. I've read about using package_data in my setup.py and then using importlib.resources to access the data files at runtime (as ...
markph7's user avatar
  • 11
0 votes
1 answer
130 views

In order to use the image, I use the following commands bg = Photo Image(file = "DNA.png") label1 = Label(window, image = bg) label1.place(x = 0, y = 0) window.iconbitmap('DNAChain.ico') ...
Mr. Iluminat's user avatar
0 votes
1 answer
92 views

I would like to import from the current working directory. For example: import os import pathlib import tempfile from importlib import import_module with tempfile.TemporaryDirectory() as temp_dir: ...
Tom de Geus's user avatar
  • 6,053
0 votes
2 answers
191 views

I am finalizing a project where I need to split the requirements.txt , helper_functions.py and , libraries.py -libraries that are used within the functions- into (3) separate files for code ...
Wael's user avatar
  • 17
2 votes
1 answer
506 views

Problem: Following a quicksart guide in official docs (https://mlflow.org/docs/latest/tracking/autolog.html), every time I try running mlflow ui --port 8080 inside parent directory with particular ...
JoshJohnson's user avatar
0 votes
1 answer
34 views

(old title: Resolve ModuleNotFoundError on import from module imported by file name) I have the following project structure . Root |--lambdas/ | |-- lambda-1/ | |-- lambda_function.py | |...
kal's user avatar
  • 81
0 votes
0 answers
72 views

I have stumbled across a weird problem when reloading modules for which I have found a solution on the internet. However, I am missing an explanation of why this problem occurs (especially regarding ...
Guest's user avatar
  • 88
1 vote
1 answer
633 views

I'm trying to build a Python project. I use Poetry to manage dependencies. In my pyproject.toml, I have the following: [tool.poetry] name = "gitdida" version = "0.2.0" My ...
Aldwen's user avatar
  • 11
3 votes
1 answer
93 views

I am looking for a solution to the following problem. I have a package that includes some build tools (for use with SCons, though that is just incidental to the question). I want the package to be ...
Ben Farmer's user avatar
  • 2,974
0 votes
0 answers
212 views

I am creating a Python package that needs certain data files in order to work. I've been looking for a way to include these data files with the package installation. I found a way using importlib....
MillerTime's user avatar
2 votes
0 answers
149 views

The little program below is almost a copy-paste for an example form Astropy website. The program works fine under PyCharm environment but when trying to make it executable using PyInstaller, I'm ...
Michel Michaud's user avatar
0 votes
0 answers
59 views

I am trying to use the prefix modl and iterate through .py files that I use as settings. I'd like to stick to python files because it is easy to declare functions and variables and import them. The ...
tincan's user avatar
  • 412
1 vote
2 answers
1k views

Lazy imports in Python have been long discussed and some proposals (for example the PEP609 - Lazy Imports) have been made to make it a built-in (optional) feature in the future. I am developing a CLI ...
atteggiani's user avatar
1 vote
3 answers
3k views

I'm trying to install scrapy on python 2.7. The problem is that when it's time to compile it I get this error $ sudo python2 -m pip install scrapy DEPRECATION: Python 2.7 reached the end of its life ...
Numbeon's user avatar
  • 21
1 vote
1 answer
138 views

I want to read metadata from a python package to feed a table withsome informations. The package is build using setuptools so all urls are saved under the [project.urls] field in the pyproject.toml ...
Pierrick Rambaud's user avatar
0 votes
0 answers
772 views

Getting Module Not found Error:No Module named 'importlib.resources' Module not found error in windows 7 python version 3.7 I'm trying to run one picture in terminal using python programming after I ...
Hari Prakash S's user avatar
0 votes
1 answer
4k views

I'm having a hard time understanding the python importlib library. I've seen 2 implementations to dynamically import modules: 1. spec = importlib.util.spec_from_file_location(name, path) module = ...
Michael's user avatar
0 votes
0 answers
134 views

I can use from importlib import abc and from importlib import util normally on Python 3. However, when I have to run the same code on Python 2.7, I got ImportError. I found that importlib2 seems to be ...
yujiaErika's user avatar
1 vote
1 answer
3k views

I am trying to build Electron (basically Chromium) on Fedora Rawhide. The distro (as of 2023) ships with Python 3.12. One of the scripts ran during build fails due to a missing imp module. The ...
kinokijuf's user avatar
  • 994
0 votes
1 answer
26 views

The following works in my python package: import Top.Lower However, the following does not work: import Top print(Top.Lower) I'm using packages = find: in my setup.cfg as well as: [options....
Sam Lerman's user avatar

1
2 3 4 5
9