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:
- I have the directory
C:\Users\Me\OneDrive\CustomModules\MathFunctions
. - Added
C:\Users\Me\OneDrive\CustomModules
to my system environment PATH. - Under
MathFunctions
, I have 2 files:__init__.py
andFunctions.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?
No comments:
Post a Comment