#๐Ÿ”’ can't import module in same directory

43 messages ยท Page 1 of 1 (latest)

torpid monolith
#

As shown in both pictures, both modules are in the same folder yet it doesn't seem to work.

upbeat iglooBOT
#

@torpid monolith

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

cerulean locust
torpid monolith
cerulean locust
#

oh hang on

#

So you probably just need to add __init__.py file in there

#

Leave it empty is fine

#

Put __init__.py in the logo_modules folder

torpid monolith
#

i'm not familiar with init thig but okay i'll try

#

this is driving me insane

#

didn't work either

#

i'll try creating folder for the get_colors file

#

ModuleNotFoundError: No module named 'colors'

#

didn't work either

cerulean locust
#

please paste as text

#

but in code block format

#

!code format instructions below

upbeat iglooBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

torpid monolith
#

you want the code of get_colors.py ?

cerulean locust
cerulean locust
#

the one that triggered the error

torpid monolith
#

gotcha

cerulean locust
torpid monolith
#

but they are just bunch of files calling each other

cerulean locust
#

like from .get_colors import get_colors

torpid monolith
cerulean locust
cerulean locust
torpid monolith
cerulean locust
# torpid monolith

so it seems that your calling the file from outside of the logo_modules

cerulean locust
dusk iron
torpid monolith
#

but i still don't get it as both files ar ein the same directory

cerulean locust
#

if you tried from get_colors import get_colors outside of logo_modules folder, Python will try to look for get_colors.py outside of logo_modules

upbeat iglooBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.