The import statements executed from the pth files seem to execute fine. But I don’t seem to be able to access any of the modules that are imported in this way.
What is this sorcery?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From your comments I’m guessing that you’re getting NameError exceptions for some modules due to confusion about the purpose of
.pth-files.pthstands forpath. The purpose is to add paths tosys.path(pythonpath – path that Python uses to find modules during import). Seesitemodule documentation.The lines that start with
importcan contain any code but generally they modifysys.path. For example,setuptoolsmachinery:Another common case is when
.pth-files are used to implement “namespace” packages:.pth-files are not there to make module names appear in your code. To importsome_module, add at the top of each module where you want to use it: