pth file is not processed

1.5k Views Asked by At

I was trying to add some folders to my path, so I added a .pth file to my site-packages folder. When it didn't work (I printed sys.path and it doesn't contain any of the paths I wrote in the file) , I tried to find the .pth file from within python and I noticed that the name of one of the folders in the path contains a . in it.

Could that be the reason why the .pth file wasn't processed? or any other suggestions why Its not working?

I don't think I can change the folder name, it was created when I created a virtual environment, and I think that if I'll change it, it might mess up other things.

The path to the .pth is - home/pomicelltohar/venv/3_6/lib/python3.6/site-packages/pomicell.pth

sys.path is

['', '/home/pomicelltohar/venv/3_6/lib/python36.zip', '/home/pomicelltohar/venv/3_6/lib/python3.6', '/home/pomicelltohar/venv/3_6/lib/python3.6/lib-dynload', '/home/pomicelltohar/anaconda3/lib/python3.6', '/home/pomicelltohar/venv/3_6/lib/python3.6/site-packages']

2

There are 2 best solutions below

0
On BEST ANSWER

The problem was that I wrote the paths in the .pth file with ~/ instead of using the full path /home/pomicelltohar

1
On

I have experienced a similar issue where my file contained the correct path but it was not processed. Maybe someone has the same issue. The file was being saved with wierd encoding UTF-16 BOM.

This was the output of powershell:

$my_modules_path| Out-File $my_pth_file

I could debug this by checking the output file in notepad++, where that enconding was selected instead of the UTF-8 that is now in the photo:

encoding from notepad

So what i did is saving it with ANSI:

$my_modules_path| Out-File -encoding ASCII $my_pth_file