1

When I execute:

echo $PYTHONPATH

on command line I get the following output:

/home/nehal/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages:/home/nehal/anaconda3/lib/python3.6/site-package‌​s:/home/nehal/anaconda3/lib/python3.6/dist-package‌​s:/home/nehal/anaconda3/lib/python3.6/dist-package‌​s:/home/nehal/anaconda3/lib/python3.6/dist-package‌​s:/home/nehal/anaconda3/lib/python3.5/dist-package‌​s:/home/userx/anaconda3/lib/python3.5/dist-package‌​s:/home/userx/anaconda3/lib/python3.5/dist-package‌​s:/home/userx/anaconda3/lib/python3.5/dist-package‌​s

I looked into .bashrc file and found only one PYTHONPATH set

export PYTHONPATH="/home/nehal/anaconda3/lib/python3.6/site-package‌​s:$PYTHONPATH"

I also looked into .profile, /etc/environment and /etc/profile but nowhere could I find PYTHONPATH.

My question is where did the above extra paths come from?

  • 1
    There is a FILES section man bash, check it for list of files, but please note that it could change from distro to distro – user996142 May 8 '18 at 18:12
  • 1
    See those dist-packages, and site-packages directories? Those are probably from when you installed ros and anaconda3. Check and see what other files you are sourcing in your .bashrc – Lucas Ramage May 8 '18 at 19:51
  • @nrb Is there a .bash_profile? – Nasir Riley May 8 '18 at 23:11
  • @NasirRiley No, Why? – nrb May 8 '18 at 23:26
  • @nrb Because depending on the environment, that file usually exists to initialize bash sessions as does .bashrc. – Nasir Riley May 8 '18 at 23:30
3

You can figure out which files are being sourced by tracing which files bash opens:

strace -e open bash -l

This should print out all the files bash tries to open (many of which are C libraries you can ingore). That should give you hints about where to look. (The "-l" option to bash asks it to run as a "login" shell, which generally causes bash to parse a few more startup files.)

0

On startup 'bash' loads it's settings from many files. Most of them usually live in subdirectories of '/etc' directory. So I would run the following command to find all files containing 'PYTHONPATH':

grep -R PYTHONPATH /etc 2>/dev/null

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.