OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Problem with importing Python module in VsCode

  • Thread starter Thread starter Bình Mai Thanh
  • Start date Start date
B

Bình Mai Thanh

Guest
I'm learning Python and wanted to make a snack store management application. When I try to import authenticate logic, it shows the following error:

Code:
Traceback (most recent call last): File "/Users/mac/Dev/Learn_python/btl/snack_app/source_code/views/login_screen.py", line 5, in <module>
import source_code.controllers.authenticate as auth 
ModuleNotFoundError: No module named 'source_code'

My import code looks like this: import controllers.authenticate as auth

I use Venv and in the image is the structure of the project
The code structure


I think vscode confirmed the module exists because it shows green in the code like this
VSCode confirm


I don't know what's wrong.

I tried adding source_code.controllers and the error became ModuleNotFoundError: No module named 'source_code'.

I activated Venv (If that matters).
<p>I'm learning Python and wanted to make a snack store management application.
When I try to import authenticate logic, it shows the following error:</p>
<pre><code>Traceback (most recent call last): File "/Users/mac/Dev/Learn_python/btl/snack_app/source_code/views/login_screen.py", line 5, in <module>
import source_code.controllers.authenticate as auth
ModuleNotFoundError: No module named 'source_code'
</code></pre>
<p>My import code looks like this:
<code>import controllers.authenticate as auth</code></p>
<p>I use Venv and in the image is the structure of the project
<img src="https://i.sstatic.net/XIx6FbQc.png" alt="The code structure" /></p>
<p>I think vscode confirmed the module exists because it shows green in the code like this
<img src="https://i.sstatic.net/ZXhsSqmS.png" alt="VSCode confirm" /></p>
<p>I don't know what's wrong.</p>
<p>I tried adding <code>source_code.controllers</code> and the error became <code>ModuleNotFoundError: No module named 'source_code'</code>.</p>
<p>I activated Venv (If that matters).</p>
 

Latest posts

I
Replies
0
Views
1
Ihsan Sadat
I
Top