TL;DR
What are the options on Windows 10 to run from command line a python script specified by a relative path? Can environment variables be changed to do so? How can this be done?
LONG
I am using Windows 10. When I follow this installation guide (written for Linux), everything is fine until I need to perform the following on Windows
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
On Windows, I added the two paths (the entire, absolute, path) to PYTHONPATH. When I execute the following; I see the extra two paths added.
C:\User\me> python -c "import sys; print(sys.path)"
However, if I create a simple test.py script
print("Relative path works")
and run it from the command line:
C:\User\me> python test.py
it works if the test.py file is saved in C:\User\me\, but NOT when it is saved in the folders of PYTHONPATH.
This SO Q&A says that
PYTHONPATH is used by the python interpreter. It is not the same as Windows' PATH environment variable. You can't use it as a search path for passing files to the interpreter on the command line.
But I could not find how I can achieve what I need, using relative path of script to run it from command line. Please note that using the absolute path is not an option, because the instalation guide requires 2 folders are added to the PYTHONPATH, in order for the task to work.
It should be possible but I did not find any answer - Python 3 documentation describes Command line option for running script with relative path:
Execute the Python code contained in script, which must be a filesystem path (absolute or relative) referring to either a Python file...