I am attempting to solve a weird issue related to importing modules in a Python script I have written. The file that implements the module is in the same directory as the main Python script.
The Python script works perfectly when I use ActivePython. However, when I use the Embedded Distribution I get the following error.
ModuleNotFoundError: No module named 'pyWhich'
I have traced the difference in behavior to the way the sys.path veritable is set in the Embedded Distribution.
In ActivePython, the environment in which my script works, the first entry in sys.path is the directory containing the script. In the Embedded Distribution, there is no entry for the directory containing the script.
The Embedded Distribution uses a _pth file to set the sys.path. I am using the default ._pth file, which I have included below for your convenience.
python36.zip
.
# Uncomment to run site.main() automatically
#import site
My question is, what magical incantation do I need to add to my _pth file to tell Python to please put the directory containing any script I run in sys.path so my scripts will work with the Embedded Distribution. The documentation on path configuration files does not seem to contain this information.
from Script directory not included in sys.path when a ._pth is in use
No comments:
Post a Comment