0

I have a folder of this file structure:

Desktop
    tech_comp
       googledash.csv
       viz.py
       sql_load.py

       company_AL
           __init__.py
           functionloads.py
           decisionplans.py
           niches.py
           actions.py

I am working with VScode in the following path as described above: C:\Users\username\Desktop\tech_comp\company_AL

I have written a bunch of list in the decisionplans.py now I am trying to load it in the actions.py I am working with. Here is what I did.

from company_AL import decisionplans

It does not show errors in the compiler but when I run I get the following.

ModuleNotFoundError: No module named 'company_AL'

I do not intend to publish it as online as this is a private project, please how do I handle this?

Thanks in advance

JA-pythonista
  • 1,225
  • 1
  • 21
  • 44
  • What's your startup location? Since it's imported by relative paths (unless found in import paths) you need to consider this when importing. – Torxed May 04 '20 at 07:53
  • What do you mean? Not clear – JA-pythonista May 04 '20 at 07:53
  • When you run your script, in which folder do you execute from? If you open a terminal, and you navigate to a folder, to run `python `, which folder are you in? : ) (VScode uses the same principle of a "working directory" or similar) – Torxed May 04 '20 at 07:54

2 Answers2

1

You have many solutions to solve your problem :

1. Add compagn_AL folder to your PYTHON_PATH

It depends of your OS but there is tutorials that explians better than me

2. Change the PATH for your script

import sys
sys.path.append('../') # or "C:\Users\username\Desktop\tech_comp\"

and then

from compagny_AL import decisionplans

3. Import it directly (not recommended)

You can just

import decisinplans
CofeDrink68
  • 179
  • 1
  • 2
0

I think you just need to do import decisionplans or from .company_AL import decisionplans because you are already in the company_AL.

Polivicio
  • 71
  • 1
  • 1
  • 12