PDA

View Full Version : [SOLVED] Error Message After Changing PATH Variable



plinydogg
September 6th, 2009, 06:06 PM
Hello,

I wanted to change my PATH variable every time I opened a new terminal session so that I could execute some Python scripts from wherever I was. After searching these forums, I learned that to do this I needed to:

(1) open /home/[username]/.bashrc
(2) Add this:


PATH=$PATH:$HOME/<Desired Directory>
export $PATH

I did this and it worked (i.e., I can execute python scripts from any directory in the terminal), but oddly, whenever I open a new terminal I get the following error (even though everything works):


bash: export: `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/ben/Development/Python/Scripts': not a valid identifier

Does anyone know what's going on here?

Thanks!

blazemore
September 6th, 2009, 06:54 PM
Could you remove the export path line from that file, considering it's throwing up an error message and everything else works?

scragar
September 6th, 2009, 06:57 PM
export PATH
No $

blazemore
September 6th, 2009, 06:59 PM
export PATH
No $

haha yes I just realised that. It's exporting the VALUE of Path, rather than the variable itsself!

blazemore
September 6th, 2009, 06:59 PM
So basically change it to

PATH=$PATH:$HOME/<Desired Directory>
export PATH

plinydogg
September 6th, 2009, 09:07 PM
You guys are awesome! Thanks, that fixed it!

andrew.46
September 7th, 2009, 12:14 AM
Hi blazemore,


So basically change it to

PATH=$PATH:$HOME/<Desired Directory>
export PATH

It really is neither here nor there but you could shorten the syntx by one line:


export PATH=$PATH:$HOME/<Desired Directory>

The classic place to add to the path for your own scripts and the like would be $HOME/bin but of course you can add any path or combination of paths.


Andrew

plinydogg
September 7th, 2009, 12:58 AM
Thanks, that's good to know about $HOME/bin...

andrew.46
September 7th, 2009, 01:51 AM
Hi plinydogg,


Thanks, that's good to know about $HOME/bin...

Well it is not a particularly special location but it is conventionally used to house your own scripts. Thus you have /usr/bin for system binaries, applications and scripts, /usr/local/bin for local-machine binaries, applications and scripts and finally $HOME/bin for personal scripts and applications. It is a neat hierarchy that you can completely ignore if you want, it is your system after all :-).

Andrew

scragar
September 7th, 2009, 02:06 AM
Hi plinydogg,



Well it is not a particularly special location but it is conventionally used to house your own scripts. Thus you have /usr/bin for system binaries, applications and scripts, /usr/local/bin for local-machine binaries, applications and scripts and finally $HOME/bin for personal scripts and applications. It is a neat hierarchy that you can completely ignore if you want, it is your system after all :-).

Andrew

/me blushes because he has system binaries in ~/bin (or rather symlinks to them) and his own executables in /usr/bin...