0

I've been following the guide here for creating and importing your own custom modules, but I seem to be missing something.

So far, i have done:

  1. I have the directory C:\Users\Me\OneDrive\CustomModules\MathFunctions.
  2. Added C:\Users\Me\OneDrive\CustomModules to my system environment PATH.
  3. Under MathFunctions, I have 2 files: __init__.py and Functions.py.

After starting Python, simply typing

from MathFunctions import Functions  # Doesn't work

as the guide shows doesn't work.

However, if I use the os.chdir() first, it works:

import os                                       # Works
os.chdir('C:/Users/Me/OneDrive/CustomModules')
from MathFunctions import Functions

Is there some way to avoid using os.chdir()? Or is that a necessary step every time?

AdmiralWen
  • 701
  • 6
  • 16

0 Answers0