Questions tagged [python-module]
A module is a file containing Python definitions and statements.
python-module
2,080
questions
0
votes
0
answers
16
views
Importing a Local Module from a Different Directory in Python 3
I have seen this question asked in numerous other posts, but none of the answers seem to work for my situation using Python 3. I have a simple repository I am working in; call it my workspace, named ...
1
vote
1
answer
57
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
61
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
0
answers
15
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
43
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
56
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
84
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
71
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
79
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
38
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
0
answers
25
views
Can't install/find modules via Python code (while compiled)
I have a Python script that when ran in the ide and/or as a .py file in general, it works just fine. All the modules are found and imported properly. Then the issue arose, for some reason when I ...
0
votes
1
answer
62
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
88
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
0
answers
19
views
How to deal with error when pybind11 setuptools building
I am using pybind11 setuptools to build a python module(.pyd), but an error occurred:
executing :error: command 'C:\Program Files\Microsoft Visual
Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\...
0
votes
1
answer
51
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 ...
0
votes
0
answers
21
views
Absolute import to access a python module in a directory above
I have the above file structure. Within src/jobs there is a file common.py which has code that will be reused across all the different jobs. Each job will be in a separate sub-directory. I want to ...
-2
votes
1
answer
58
views
I have a problem running python code in vs terminal
Unable to find python module. it prints that multiple times
I tried to download the same version of my vs python which is 3.11.7 in my terminal by using the command pip install python 3.11.7 but it ...
0
votes
0
answers
12
views
Visual Studio Code cannot find one of my modules, but cmd can find it without issue using the same methods
When using a venv I cannot find my neat module. This image shows that I have installed the module, have selected the right venv and it still doesn't work. This image shows that attempting the same in ...
2
votes
1
answer
68
views
File size overhead reduction of C++ wrapping by Cythonization
I have the following minimal example of summing an array (taken from here):
#lib.cpp
template<typename T>
T arr_sum(T *arr, int size)
{
T temp=0;
for (int i=0; i != size; ++i){
...
0
votes
1
answer
40
views
Directly import modules in a Poetry project from a non-Poetry managed module
I have an existing codebase that I am working in, and for any new code, I am using Poetry to manage the modules, dependencies, etc. For existing code, I am slowly migrating over code, but this is ...
2
votes
2
answers
147
views
Python module with name __main__.py doesn't run while imported
Somebody asked me a question and I honestly didn't try it before, So it was interesting to know what exactly happens when we name a module __main__.py. So I named a module __main__.py, imported it in ...
0
votes
1
answer
135
views
How to import Python module into a Python script in Glue AWS
I have a project with this structure:
└── external_variables
├── anatel_access_data linux.py
├── anatel_access_data.py
├── bsria_variables.py
├── future_external_variables.py
├── ...
0
votes
0
answers
38
views
Python ModuleNotFoundError for command line tools built with setup.py
I am trying to build a simple command line tool and package it with setup.py. Here's my directory structure.
├── s3_md5
│ ├── __init__.py
│ ├── cmd.py
│ └── src
│ ├── __init__.py
│ ├─...
0
votes
0
answers
29
views
Import local modules in Python with relative path
TopLevelDir
├── CommonUtils
│ ├── setup.py
│ └── Sql
│ ├── class1.py
│ └── class2.py
├── Project1
│ ├── requirements.txt
│ ├── venv
│ ├── main.py
│ └── FolderA
│ ├── ...
0
votes
0
answers
47
views
Problems with transitive imports in Python3 [duplicate]
I'm having a problem with some (likely badly-written) Python2 code, which I'm trying to convert to Python3. I'm sure this has been answered somewhere else before, but my Google-fu is not up to this ...
2
votes
1
answer
38
views
PyGame - functions in other files are not defined
Been making my first PyGame project and previously after clicking on "start game" button it would take user to the gameplay window, whereas now it claims gameplay is undefined. I have tried ...
0
votes
0
answers
54
views
Error in import module Flask application deploy in vercel using vercel.json
I'm encountering an issue while attempting to deploy my Flask application to Vercel using a vercel.json file. My application consists of a main.py file where the application is initialized. This file ...
0
votes
0
answers
24
views
imported python module of functions does not recognise package imports
I have files in a repo with the following Structure:
RepoName\main.py
RepoName\functions\myfunction.py
Inside myfunction.py is:
import pandas as pd
def make_ticker_list():
constituents = pd....
0
votes
2
answers
79
views
How do I reload a python module?
This has been asked 1000 times before, but nothing seems to work for me.
Using Python3.9 and VScode, though I have tested it making edits with just the plain TextEdit app on mac as well.
I cloned this ...
0
votes
1
answer
110
views
Python isn't recognizing my speech to text in a way I can use it in if statements
I'm currently building a personal assistant using python, and I got it to work to a certain extent. I have been using this video tutorial. I am getting the assistant "harvey" to say all ...
2
votes
2
answers
981
views
How do I troubleshoot "ModuleNotFound" errors
I often run into issues where my own modules are not found in python, and while I've been addressing them on a case-by-case basis, I don't really feel like I know how to actually troubleshoot them. It ...
0
votes
2
answers
157
views
No module named 'whois' Despite Already Installing 'python-whois'
Context
I am making a project using Python and have a virtual environment installed called venv. Here is the information for the virtual environment:
Version and Modules Installed:
I am on a linux ...
0
votes
1
answer
97
views
How to check if a Python module with a custom __getattr__ has a given attribute?
I implemented a custom __getattr__ on a module that retrieves a value and caches it with setattr. Here is the simplified version:
# mymodule.py
import sys
__this = sys.modules[__name__]
def ...
0
votes
2
answers
45
views
Unable to install any modules with Pip and this error
enter image description here
I have installed python on my windows laptop appropriately but am unable to use or execute many things due to this kind of error. How do I come out of the shell and ...
0
votes
1
answer
69
views
How to import a Python class from a directory which has dependency in the same directory?
I want to use a class A, which is in a subdirectory dir in file A.py. It has dependency with file B.py which is also in the same directory dir. I want to use the A class from its parent directory. The ...
1
vote
2
answers
71
views
Python ModuleNotFoundError only in command line execution not in IDE
I see a ModuleNotFoundError error when running a simple program.
The project is created using Poetry, and the setup is as shown in the screenshot.
h.py has this:
def add(num1, num2):
return num1 +...
1
vote
1
answer
77
views
python import functions in multiple files from top level folder
I have a directory structure that looks like the following;
file.py
module1/
__init__.py
module1_file1.py
module1_file2.py
Lets say module1_file1.py has a function foo and module1_file2....
0
votes
0
answers
66
views
Can't get pyttsx3 to run on intel Mac
This is the code:
import pyttsx3, PyPDF2
pdfreader = PyPDF2.PdfReader(open('D2DStuff.pdf', 'rb'))
speaker = pyttsx3.init()
clean_text = ''
for p_num in range(len(pdfreader.pages)):
text = ...
0
votes
0
answers
12
views
Error with importing requests module on VSCode for Python
I get this output when I try to pip install requests
I want to install requests and am unsure how to solve this problem. I have attempted many options to fix this problem and none have worked. I am ...
0
votes
0
answers
71
views
Cannot import installed python module
from binance.spot import Spot
client = Spot()
# Get server timestamp
print(client.time())
I installed the module with the pip install command, but I get the “ModuleNotFoundError: No module named '...
0
votes
1
answer
115
views
Why the Window Title in the notification system of plyer isn't working
I have implemented the following code:
from plyer import notification
def createNotification(title, message):
notification.notify(
title=title,
message=message,
app_name=&...
0
votes
0
answers
32
views
I am having a problem with the module mp3play
import mp3play
import time
loc=r'C:\Users\user\Desktop\Francisco\music.mp3'
tocar=mp3play.load(loc)
tocar.play()
time.sleep(10)
I used this code to try to play an mp3 file on my computer but I ...
0
votes
2
answers
157
views
"No module named X" error even with sys.path.append
so I have a project with this directory structure:
app
|
__init__.py
some_python.py
scripts
|
some_script.py
I want to import a function from some_python.py in some_script.py, so I use this ...
0
votes
1
answer
73
views
Python modules not found when using relative path names
I am running a script which uses the TQDM package. I ran the code in command prompt using the full path, which worked fine, but when I ran the same program using the relative path, it could not find ...
2
votes
0
answers
479
views
"Module does not explicitly reexport attribute" Mypy implicit-reexport
I have a python library of the following structure:
module
> module_namespace
__init__.py
MyClass.py
> asyncio
__init__.py
MyClass.py
In the ini.py files I have ...
1
vote
0
answers
71
views
Python 3.11 C Module
I am trying to create a Python module in C, however when I load it I get the following message.
Fatal Python error: _PyInterpreterState_GET: the function must be called with the GIL held, but the GIL ...
0
votes
0
answers
41
views
Pickle the python module so that after loading it I can use it normally even if there are no .py files that correspond to that module anymore
Pickle can not dump modules at all, and dill python library can. But I was not able to figure out how I can dump it with dill so that it doesn't "ask" for having source python files that ...
0
votes
0
answers
19
views
python package installed in wrong working enviroment [duplicate]
I installed sklearn using pip install.
whoever I can't use it, I think because it installed in different working enviroment.
The following code is for more information.
import sys
print(sys.executable)...
2
votes
1
answer
1k
views
ModuleNotFoundError: No module named 'src' even after adding path
I'm attempting to import some functions from src, but I keep getting the error "ModuleNotFoundError: No module named 'src'". I've added src to the path, but to no avail. Here is my directory ...
0
votes
1
answer
61
views
Importing a dictionary from a python file who's name is only known at runtime
I'm currently making a system that allows users to write a dictionary in new .py files(which are created in a seperate folder in the same directory) and then access that dictionary. I have the ...