python-module

Getting button input from module on tkinter python

Getting button input from module on tkinter python Question: I am working on a project that uses buttons, but I would like to make it modular. The only problem I can’t seem to get pass by is getting if someone is pressing the button from a different file -file 1 from tkinter import* class app2: …

Total answers: 1

Find list comprehensions in python modules, using a regex

How can I find list comprehensions in Python code? Question: I am trying to refactor some Python modules which contain complex list comprehensions than can be single or multiline. An example of such a list comprehension is: some_list = [y(x) for x in some_complex_expression if x != 2] I attempted to use the following regex …

Total answers: 2

ImportError: cannot import name 'Iterable' from 'collections' in Python

ImportError: cannot import name 'Iterable' from 'collections' in Python Question: Working in Python with Atom on a Mac. Code: from rubik.cube import Cube from rubik_solver import utils Full error: Traceback (most recent call last): File "/Users/Audey/Desktop/solver.py", line 2, in <module> from rubik_solver import utils File "/Users/Audey/Library/Python/3.10/lib/python/site-packages/rubik_solver/utils.py", line 4, in <module> from past.builtins import basestring File …

Total answers: 4

ModuleNotFoundError: No module named 'sharedFunctions'

ModuleNotFoundError: No module named 'sharedFunctions' Question: I have a Python project in which I have the following folder structure: > root > download_module > __init__.py > downloadProcess.py > sharedFunctions.py > someHelper.py > useSharedFunction.py The download_module/__init__.py has the following code: from .sharedFunctions import stringArgumentToDate from .downloadProcess import downloadProcessMethod The sharedFunctions.py file contains the following function: def …

Total answers: 1

How to zip a file in python?

How to zip a file in python? Question: I have been trying to make a python script to zip a file with the zipfile module. Although the text file is made into a zip file, It doesn’t seem to be compressing it; testtext.txt is 1024KB whilst testtext.zip (The code’s creation) is also equal to 1024KB. …

Total answers: 3

importing class from another file gives error when working and no error when not working

importing class from another file gives error when working and no error when not working Question: I am attempting to import a class named MainMenus from this file B:ProgrammingPythonRaceDashsrcUIModulesMenus.py here is the code for the class class MainMenus: def StartUp(): #do stuff def MainMenu(): #doing other stuff I also have the _init_.py file in this …

Total answers: 2

No module named pipreqs.__main__; 'pipreqs' is a package and cannot be directly executed

No module named pipreqs.__main__; 'pipreqs' is a package and cannot be directly executed Question: I am trying to use pipreqs module to generate requirements text. But pipreqs is generating following error. No module named pipreqs.__main__; ‘pipreqs’ is a package and cannot be directly executed I’m using Visual Studio Code, and trying to use pipreqs by …

Total answers: 1

How to install external modules in a Python Lambda Function created by AWS CDK?

How to install external modules in a Python Lambda Function created by AWS CDK? Question: I’m using the Python AWS CDK in Cloud9 and I’m deploying a simple Lambda function that is supposed to send an API request to Atlassian’s API when an Object is uploaded to an S3 Bucket (also created by the CDK). …

Total answers: 6

No module named 'PyPDF2' When Trying to Import

No module named 'PyPDF2' When Trying to Import Question: I am attempting to Import PyPDF2 in order to read a PDF file and parse through it. I am using a Raspberry Pi, and have installed PyPDF2 using the command pip install PyPDF2. However, when I try importing it, I am getting ModuleNotFoundError. I think it …

Total answers: 4

What is the reason for using a wildcard import?

What is the reason for using a wildcard import? Question: I have just learnt about importing modules, and I am a bit confused about the wildcard import. from module_name import * I do not understand the reason of using it at all, I see people saying not to use it at all. Could someone clarify …

Total answers: 3