Relative imports - ModuleNotFoundError No module named x

0 votes

I have these  two files:

  1. test.py
  2. config.py

These are the following functions stung to config.py:

config.py

debug = True

test.py

import config
print (config.debug)

But I am getting this error:

ModuleNotFoundError: No module named 'config'

The py3 convention is to use absolute imports:

from . import config

However, this leads to the following error:

ImportError: cannot import name 'config'

 Can someone help me solve this?

May 23, 2022 in Python by Kichu
• 19,040 points
1,714 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

+1 vote
3 answers
+2 votes
3 answers

ModuleNotFoundError: No module named 'Crypto'

The module you’ve installed is different. To install ...READ MORE

answered Aug 20, 2019 in Python by Raman
81,283 views
+3 votes
3 answers

ModuleNotFoundError: No module named 'cv2'

Hi@akhtar, This error may occur if you didn't install ...READ MORE

answered Apr 9, 2020 in Python by MD
• 95,460 points
270,957 views
0 votes
2 answers

ModuleNotFoundError: No module named 'pythoncom' in pyttsx3

even i faced the same problem ...just ...READ MORE

answered Jun 2, 2020 in Python by anonymous
14,028 views
+2 votes
2 answers

ModuleNotFoundError: No module named 'pyttsx3

Hi@akhtar, To avoid this error you have to ...READ MORE

answered Apr 24, 2020 in Python by MD
• 95,460 points
29,235 views
0 votes
1 answer

ModuleNotFoundError: No module named 'Foundation'

Hi@akhtar, By default Foundation module comes with Anaconda ...READ MORE

answered Apr 24, 2020 in Python by MD
• 95,460 points
4,093 views
0 votes
1 answer

Relative imports in Python 3

Because the first statement, from.mymodule import myfunction, ...READ MORE

answered Feb 16, 2023 in Python by Rishu
• 300 points
1,147 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 58,020 points
1,699 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 14, 2018 in Python by Priyaj
• 58,020 points
873 views
0 votes
1 answer

“stub” __objclass__ in a Python class how to implement it?

You want to avoid interfering with this ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 58,020 points
2,378 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP