python-import

Import error when trying to import python module from other folder

Import error when trying to import python module from other folder Question: This is my project structure: /my_project /first_folder first.py /second_folder second.py second.py def hello(): print(‘hello’) first.py from ..second_folder import second second.hello() when i run first.py i get the following error: ImportError: attempted relative import with no known parent package How can I avoid this …

Total answers: 2

Can't pickle <class>: import of module failed

Can't pickle <class>: import of module failed Question: I am using https://github.com/ekonda/kutana. plugins/test.py: from kutana import Plugin import pickle plugin = Plugin(name="Tictactoe", description="Tictactoe Game", invites={}, games=[]) @plugin.on_start() async def _(): plugin.games = [Game()] # Backup games when bot is shutting down @plugin.on_shutdown() async def _(): try: with open("games.pickle", "wb") as f: pickle.dump(plugin.games, f) except Exception …

Total answers: 2

face recognition Library in python install error

face recognition Library in python install error Question: I installed cmake,opencv,dlib and face_recognition and all of them are installed succesfully without any error when i try to import face_recognition import face_recognition I get this error Traceback (most recent call last): File "c:UsersWAJIHDesktoppop.py", line 1, in <module> import face_recognition ValueError: source code string cannot contain null …

Total answers: 2

How can I tell which module/script has just run this script in Python?

How can I tell which module/script has just run this script in Python? Question: I have a module called detector.py, and I want to import the module Vimba into it only if detector.py is being imported by experiment.py. Is this importer-specific conditional importing possible? If I import this module (detector.py) into a different module, say …

Total answers: 1

import pyautogui does not work in VSCode, despite having everything installed

import pyautogui does not work in VSCode, despite having everything installed Question: Im learning Python at the moment and I am trying to work with pyautogui at the moment but I have encountered a very basic problem and while I found other questions like this, I did not find a solution. My "Setup": I am …

Total answers: 1

VS code: Updated PYTHONPATH in settings. Import autocomplete now works, but module not found when running program

VS code: Updated PYTHONPATH in settings. Import autocomplete now works, but module not found when running program Question: I have been trying to fix a problem while running python files in VSCode. I have a directory with a program my_program.py that imports a module personal_functions.py from a folder packages_i_made. project ├── .env └── folder_a ├── …

Total answers: 2

Struggling with python's import mechanism

Struggling with python's import mechanism Question: I am an experienced java enterprise developer but very new to python enterprise development shop. I am currently, struggling to understand why some imports work while others don’t. Some background: Our dev team recently upgraded python from 3.6 to 3.10.5 and following is our package structure src/ bunch of …

Total answers: 2

Can I import default Python modules in a Python Docker image?

Can I import default Python modules in a Python Docker image? Question: I am new to Docker, and as a learning exercise, I want to make a custom Python package available through a Docker image. The package is called hashtable-nicolerg and includes a HashTable class that can be imported with from hashtable_nicolerg.hashtable import HashTable. It …

Total answers: 2

Python, Import config.py

Python, Import config.py Question: # config.py white = (255,255,255) # main.py import config print(white) # output: Traceback (most recent call last): File "C:…TestTest2.py", line 2, in <module> print(white) NameError: name ‘white’ is not defined Process finished with exit code 1 # wanted output (255, 255, 255) Process finished with exit code 0 Hello I want …

Total answers: 1