tags:

views:

1252

answers:

3
+1  A: 

How are you "inserting" the additional paths?

Modifying the path is done the same way any other list in Python is modified - although it sounds like you're simply clobbering it by re-assigning it.

Example of updating sys.path: http://www.johnny-lin.com/cdat_tips/tips_pylang/path.html

Jon
+4  A: 

You really need to post some code for us to be able to help you. However, I can make an educated guess. You say that if you make a whole new list and assign it to sys.path then it works. I assume you mean that you're doing something like this

sys.path = ["dir1", "dir2", ...]

But that if you insert the paths at the beginning then it doesn't work. My guess is that you're using the insert method, like so

sys.path.insert(0, ["dir1", "dir2"])

If so then this is incorrect. This would create a list that looks like

[["dir1", "dir2"], "dir3", ...]

You should instead say

sys.path[:0] = ["dir1", "dir2"]

which will give you

["dir1", "dir2", "dir3", ...]

But this is all guesswork until you post your code.

Eli Courtwright
+1  A: 

Example of updating sys.path taken from here

import sys
sys.path.append("/home/me/mypy")

This worked for me.

bentford