1

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

3
  • What's your startup location? Since it's imported by relative paths (unless found in import paths) you need to consider this when importing. Commented May 4, 2020 at 7:53
  • What do you mean? Not clear Commented May 4, 2020 at 7: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 <some script.py>, which folder are you in? : ) (VScode uses the same principle of a "working directory" or similar) Commented May 4, 2020 at 7:54

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.