How to set the correct environment variable for python scripts?

391 views Asked by At

I have been trying to add several paths to environment variable in windows-10 but still repeatedly getting Module not found error?

Mycurrent path to envirionment variables

when I try to run my training script I get Module not found error.

error while executing

Please help me to add correct path to envirionment so that I would not get "module not found error" ever again.

2

There are 2 answers

0
Paddy Alton On

It looks like a pretty complex directory structure. I wonder whether the fact you have a subdirectory with the same name (regression_model) as its parent is causing problems?

In general what you need to make the following happen:

  • the module you want to import should be a directory with an __init__.py file inside it
  • the parent directory of the module directory should be in the pythonpath

You could try renaming one of the directories and simplifying what's in the environment variable to match the above.

If that doesn't work

import sys

print(sys.path)

to check what the script thinks is in the pythonpath.

(you can even try using sys.path.append within the script to put the right thing into the path if all else fails! Might help with debugging.)

2
Dinesh On

you can give the path to python script like this

<python installation path>\Scripts\

you can check the python installation path in windows by entering this command in cmd.

where python