Skip to content

Tag: import

valid and corrupt lines from file

As you can read, the function validate_data should check the imported file for corrupt and valid lines, then append them to the correct list, and print them. It works, except that, as you can probably see, the lines will not print in a single line. I’m sure I have to make two other lists to append the c…

Django Standalone Script in Django 4.1

I am trying to run a standalone script in django 4.1. I have the setup as suggested in this post at the top of my file: Django Standalone Script However, on the 4th line, I get the following error: ModuleNotFoundError: No module named ‘sport_api’ This is my INSTALLED_APPS in settings.py How do I g…

Is it possible to import a folder as a module?

I have a library I’m working on that is intended to be imported like import raycekar as rk and have its individual files referenced as rk.unit.whatever. This is the directory structure: From within main.py, if I from raycekar import ui, I can access ui. If I want to import raycekar as rk, rk.ui raises a…

What is the correct way to import this class?

I have the following repository structure: In moduleB.py I need to import MyClass, I use the following command: When I run the main() function in moduleB.py I have the following error: ModuleNotFoundError: No module named ‘directoryA’ I run the moduleB.py from directoryB in the following way: How …

Imported package searches for modules in my code

Can someone explain me what is going on here and how to prevent this? I have a main.py with the following code: I outsourced some functions into a module named utils.py: When I run this I get the following output: So it seems like the torch package I imported has also a utils resource (package) and searches f…