Home > database >  Python in Vs-Code: Can't import python file
Python in Vs-Code: Can't import python file

Time:08-05

When i try to run main.py, this error appears: ModuleNotFoundError: No module named 'catalog'

main.py

from catalog.config import config
from catalog.config.log_config import app_logging_config
from catalog.es_catalog_controller import EsCatalogController

@lru_cache()
def get_settings():
    return config.Settings()


catalog_controller = EsCatalogController()

It seems that vscode does not recognize the import of files inside catalog folder, but in pycharm it runs normally. What is needed to vscode recognizes this kind of import?

CodePudding user response:

You can use shortcut "ctrl shift P" and choose the "python:select interpreter":

enter image description here

You can also click the option in the red box in the lower right corner to specify the python version:

enter image description here

After specifying the correct Python interpreter, install package by using command pip install catalog.

CodePudding user response:

make a virtual machine and then try. If u still get the error then u put the files in

  • Related