How do I set sys.path for Python IDLE sessions?

I have tried adding a path to python path in .bashrc but this had no effect within IDLE when I tested it with using import sys and print(sys.path).


.bashrc is read when bash is launched. Starting IDLE directly does not launch bash. If you launch IDLE from a terminal running bash you will see that it will be present.

|improve this answer|||||
  • But I used source ~/.bashrc,didn't that matter? – Gnijuohz Apr 4 '12 at 2:04
  • Of course that matters. For the shell you run it in. – Ignacio Vazquez-Abrams Apr 4 '12 at 2:05
  • I don't quite understand.I thought when I used source ~/.bashrc,the pythonpath in the whole system would change...So you are saying even if I reboot,the path wouldn't output in IDLE if I wouldn't launch it from the shell? – Gnijuohz Apr 4 '12 at 2:10
  • If you reboot then yes, since bash is run as part of the login sequence. – Ignacio Vazquez-Abrams Apr 4 '12 at 2:11
  • Ehh,what's the different between being run when logining and being run as in source ~/.bashrc,not the same thing?! – Gnijuohz Apr 4 '12 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.