On Sun, Aug 23, 2015 at 11:47 AM, Peter Otten <__pete...@web.de> wrote: > boB Stepp wrote: > >> On Sat, Aug 22, 2015 at 3:18 AM, Peter Otten <__pete...@web.de> wrote: >>> boB Stepp wrote:
>> ... I was not in the directory, E:\Projects\mcm. It is my >> understanding that if I start in a particular directory when I invoke >> Python, then it looks in that location first in PYTHONPATH. > > No, it looks in the location of the script, not in the working directory: [...] > You have to add the working directory explicitly, e. g.: > > $ PYTHONPATH=. python3 sub/main.py > hello Applying your wisdom to my remaining question, before I was doing this unsuccessfully: E:\Projects\mcm>py e:\Projects\mcm\test\db\test_manager.py Traceback (most recent call last): File "e:\Projects\mcm\test\db\test_manager.py", line 16, in <module> import mcm.db.manager ImportError: No module named 'mcm' But if I set the PYTHONPATH to e:/Projects/mcm as you seem to be suggesting, gives: E:\Projects\mcm>set PYTHONPATH=e:/Projects/mcm; E:\Projects\mcm>py e:\Projects\mcm\test\db\test_manager.py . ---------------------------------------------------------------------- Ran 1 test in 0.000s OK Success! Thanks, Peter! You really clarified a LOT of points that I just was spinning my wheels uselessly on. >> Peter said earlier in this thread: >> >> ------------------------------------------------ >> If you want to trigger the >> >> if __name__ == "__main__": ... >> >> you have to invoke the test script with >> >> py ./mcm/test/db/test_manager.py >> >> the same way you would invoke any other script. >> ------------------------------------------------- >> >> If I try this or begin in E:\Projects\mcm and type py >> ./test/db/test_manager.py I get >> >> E:\Projects\mcm>py ./test/db/test_manager.py >> Traceback (most recent call last): >> File "./test/db/test_manager.py", line 16, in <module> >> import mcm.db.manager >> ImportError: No module named 'mcm' This final question is resolved by setting the PYTHONPATH environment variable as above. I just want to note that this is *not* an instance where a FULL path needs to be used to run test_manager.py as I had earlier tried just above. Now after setting PYTHONPATH I get: E:\Projects\mcm>py ./test/db/test_manager.py . ---------------------------------------------------------------------- Ran 1 test in 0.000s OK I think this wraps up everything I was struggling with. Have I missed anything? boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor