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

Gaurav Jain
  • 1,549
  • 1
  • 22
  • 30

2 Answers2

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

ilyas patanam
  • 5,116
  • 2
  • 29
  • 33
Francesco Montesano
  • 8,485
  • 2
  • 40
  • 64
  • 7
    or, `python -c 'import sys; print(sys.path)'` from a regular shell ;-) – mgilson Jan 07 '14 at 07:36
  • @mgilson: thanks for saving me the bother to remember the option `-c` :D – Francesco Montesano Jan 07 '14 at 07:38
  • 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... – mgilson Jan 07 '14 at 07:48
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.

Bleeding Fingers
  • 6,993
  • 7
  • 46
  • 74
  • @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 – Francesco Montesano Jan 07 '14 at 07:37
  • @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... – mgilson Jan 07 '14 at 07:37