Python Forum
[FIXED] User-defined module: ModuleNotFoundError error in VSCode but not in PyCharm
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[FIXED] User-defined module: ModuleNotFoundError error in VSCode but not in PyCharm
#1
Dear all,

My apologies in advance for such a simple question, but I've spent hours browsing on the Net w/o obtaining a solution. I am newbie to Python and coding, and I am working on a project for my studies. I am using VSCode casue PyCharm is too heavy for my computer.

I have a project with the following structure:

Project
|_ database: __init__.py, connection.py
|_ recipes: __init__.py, recipe_modules.py, recipe_functions.py
|_ (other irrelevant packages)

The package recipe_modules.py has the following statements:
import peewee
import datetime
from database.connection import BaseModel, db
And when running the module I get the following error in VSCode:
Error:
ModuleNotFoundError: No module named 'database'
However, when I run the module in PyCharm I do not get any error - meaning the statements are correctly defined and all the rest is OK.

I know is an issue with the configuration of VSCode but I have spent hours w/o being able to fix it Wall .

Btw, my file .vscode/launch.json already has the follwing code:
{
        "env": {
            "PYTHONPATH":"${workspaceFolder}"
            }
{
I am absolutely lost here, and this is killing me. Hopefully you have already faced this.

Thanks in advance for your help!
Reply


Messages In This Thread
[FIXED] User-defined module: ModuleNotFoundError error in VSCode but not in PyCharm - by epoxy - May-30-2021, 02:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] ModuleNotFoundError: No module named 'PyQt5' matklt 2 16,872 Jun-02-2020, 07:05 AM
Last Post: Knight18
  [Kivy] ModuleNotFoundError: No module named 'kivy' Exsul 7 30,599 Mar-30-2019, 12:58 AM
Last Post: Exsul
  "ModuleNotFoundError: No module named '_tkinter' in Python 3.8 Alfa 0 programmerc 1 6,470 Oct-21-2018, 06:32 PM
Last Post: Larz60+
  [Tkinter] Scroll bar height is not fixed with Text widget MeeranRizvi 2 15,585 Feb-06-2017, 12:24 PM
Last Post: MeeranRizvi
  [pygtk] fixed.move not working as expected DennisT 4 6,236 Nov-10-2016, 11:36 PM
Last Post: DennisT

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020