I have several python versions on HP-UX.
$ python -V
Python 2.3.3
$ which python
/usr/local/bin/python
$ echo $PYTHONPATH
/usr/python-2.5.2/lib/python2.5/site-packages:/usr/python-2.5.2/lib/python2.5
In .bash_profile I set I want to use version 2.5.2, so why is used older version and where is set path /usr/local/bin/python
? How delete this path?
It appears you may be unclear about the difference between your shell PATH
(a list of directories in which the shell looks for executable programs) and your PYTHONPATH
(a list of directories which your Python interpreter will add to sys.path
, and in which it will look for importable modules and packages).
You are still using Python 2.3.3 because you haven't added the binary directory for Python 2.5.2 (presumably, from your PYTHONPATH
setting above, /usr/python-2.5.2/bin
) to your shell's PATH
. The best place to do this is in your shell initialization file, typically either ~/.bash_profile
or ~/.profile
.
You should make sure that this new entry appears BEFORE /usr/bin/local
to ensure that it is found first, otherwise the python
command will still find the Python in /usr/local/bin
. Typically you will need a statement like
PATH=/usr/python-2.5.2/bin:$PATH
Don't forget to either restart your shell or re-source the initialization file after making this change so it actually affects the shell in which you are testing.
Also note that ANY Python interpreter will always add the necessary sys.path
entries at startup time to find its installed libraries, so there is no need for a PYTHONPATH
setting such as you quote above to locate them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.