#Basic Import Question for VS Code

17 messages · Page 1 of 1 (latest)

tribal silo
#

Hi I am transferring my project from pycharm to VS Code and I want to Import files from within my project folder but different folders within my project folder:

Project:
FolderA:
file.py
FolderB:
file2.py

if I want to import file.py into file2.py, in pycharm I would use: "from FolderA import file". In VSCode this is a lot more confusing and I need help. Yes I googled it

old verge
#

Huh?

#

Imports are handled by Python, not your IDE

#

Probably module stuff with __init__.py

ember trellis
#

you need to put an empty __init__.py file in the subfolders as rob mentioned if you want to treat the folder as a module

tribal silo
#

Nah VS Code is a lot different then other IDE's

#

I got running to work but not debugging

#

Using this settings.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "${fileDirname}",
            "env": {"PYTHONPATH": "${workspaceFolder}${pathSeparator}${env:PYTHONPATH}"}
        }
    ]
}
old verge
#

Oh you always run via the funny buttons in the IDE

tribal silo
#

I've created empty init.py files as stated above and I get the exact same error

#

This didn't work either

#

This worked

#
import sys
sys.path.append('/root/miniconda3/envs/rapids-24.02/projects/NBAGambling/')
#

Thanks for nothing yall

old verge
#

😂 aggressive bambi indeed