Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import multiple locations to PYTHONPATH (bash)

I know you can add multiple locations to python path by separating them by colons ie:

export PYTHONPATH=~/one/location:~/second/location

etc.

I have several locations to add and it looks messy using the above method. Is there a way of adding them in multiple lines? This is what I tried and the last line erases the first.

export PYTHONPATH=~/one/location
export PYTHONPATH=~/second/location

Thanks

like image 239
Anake Avatar asked Apr 24 '11 15:04

Anake


People also ask

Can I have multiple Pythonpath?

Background. Setting the PYTHONPATH environment variable is an easy way to make Python modules available for import from any directory. This environment variable can list one or more directory paths which contain your own modules. On Windows, multiple paths are separated by semicolons.


1 Answers

PYTHONPATH=~/one/location:$PYTHONPATH
PYTHONPATH=~/second/location:$PYTHONPATH
export PYTHONPATH

Note the order here: I've made them so that each has higher precedence than the one before; you could switch what goes on each side of the colon if you want later entries to have lower precedence.

like image 176
John Zwinck Avatar answered Sep 30 '22 23:09

John Zwinck