8

when i do echo $PYTHONPATH it returns nothing..empty line.

so what does that mean. Im using python and it's working fine ..so whats the use of pythonpath and what should be the value of this in ubuntu 13.04

/usr/bin/

or

/usr/lib/

..or something else

and in windows we have python27/source directory where i could put external sources/drivers , where(or equivalent) it is in ubuntu.

when I do user@user$ dpkg -L python2.7 it shows

/.
/usr
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/lib-dynload
/usr/lib/python2.7/lib2to3
/usr/lib/python2.7/lib2to3/fixer_util.py
....
/usr/lib/python2.7/lib2to3/Grammar.txt
/usr/share
/usr/share/doc
/usr/share/doc/python2.7
/usr/share/doc/python2.7/NEWS.gz
/usr/share/doc/python2.7/README.Debian
/usr/share/doc/python2.7/ACKS.gz
/usr/share/doc/python2.7/README.gz
/usr/share/doc/python2.7/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/python2.7
/usr/share/applications
/usr/share/applications/python2.7.desktop
/usr/share/menu
/usr/share/menu/python2.7
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/2to3-2.7.1.gz
/usr/share/man/man1/pdb2.7.1.gz
/usr/share/man/man1/pygettext2.7.1.gz
/usr/share/man/man1/pydoc2.7.1.gz
/usr/share/pixmaps
/usr/share/pixmaps/python2.7.xpm
/usr/bin
/usr/bin/2to3-2.7
/usr/bin/pygettext2.7
/usr/bin/pydoc2.7
/usr/share/doc/python2.7/changelog.gz
/usr/share/doc/python2.7/changelog.Debian.gz
/usr/bin/pdb2.7

I've downloaded chrome driver from this site and put in given directory/usr/bin..but it's not working .where should i put this? https://code.google.com/p/selenium/wiki/ChromeDriver

2 Answers 2

13

The variable PYTHONPATH that you echo in the terminal is added to the other paths of python. So if you don't have any particular path set in your .profile or .bashrc file (or locally), the variable will be empty.

To see the path that python uses do in a python shell

import sys
print(sys.path)

Or as @mgilson suggestes, you can run from terminal

python -c 'import sys; print(sys.path)'

A note: If you decide to install by hand a package using python setup.py install --user you don't need to add $HOME/.local/lib/pythonX.X/site-packages to PYTHONPATH, as it is already in sys.path

Sign up to request clarification or add additional context in comments.

3 Comments

or, python -c 'import sys; print(sys.path)' from a regular shell ;-)
@mgilson: thanks for saving me the bother to remember the option -c :D
No problem -- I tend to use it pretty frequently to do stupid stuff like this. I frequently find myself doing stuff like python -c 'import matplotlib; print matplotlib.__version__ or the like...
1

If you want Python to have some extra set of paths in it's sys.path in every Python session apart from the default ones (site-packages etc) you add it to the $PYTHONPATH environment (local or system) variable.

Most probably you don't need it right now, leave it as it is.

Plus you'll know when you really need it populate it.

If you use site.addsitedir("path") in almost every Python path then you can add that "path" to $PYTHONPATH.

Check virtualenv.

2 Comments

@GauravJain: if you install by hand, do python setup.py install --user. It will install in $HOME/.local/lib/pythonX.X/site-packages. So you're sure that it won't interfere with system-wide packages
@GauravJain -- Usually you're supposed to install packages. I'm not too familiar with selenium or chromedriver, but python code is generally packaged with a setup.py script that you should run as an admin to install it...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.