Python.pth files not working

The directories listed in my .pth configuration file do not appear in sys.path.

The contents of the configuration file named some_code_dirs.pth :

 /home/project 

File paths:

 /usr/lib/python2.6/site-packages/some_code_dirs.pth /usr/lib/python2.6/some_code_dirs.pth 

Check sys variables in python interpreter:

 >>> print sys.prefix '/usr' >>> print sys.exec_prefix '/usr' 

All this seems necessary in the Python documentation, but sys.path does not include the / home / project directory.

Note that the interpreter adds the directory after:

 >>> site.addsitedir('/usr/lib/python2.6/site-packages') 

What am I missing here?

+6
python pythonpath
source share
2 answers

What OS are you using? On my Ubuntu 9.04 system, this directory is not in sys.path. Try putting it in /usr/lib/python2.6/dist-packages . Note that this is dist instead of site .

+4
source share

I had a similar problem. Check the encoding of your pth file. It seems that pth files are silently ignored if encoded in UTF-8 using the specification.

0
source share

All Articles