bash - New to OSX and commands are never found so I 'export' them. Is there a way to fix it for good? -


i'm new bash , mac (about week) , 3 months programming. i've been running problem ends being in bash profile.

like changing environment variables in python commands like

path="/applications/postgres.app/contents/versions/9.4/bin:$path”  export database_url=“postgresql://localhost/cheese”  export app_settings=“config.developmentconfig" 

or postgres in python work have this

export path=/applications/postgres.app/contents/versions/9.3/bin/:$path 

recently installed virtualenvwrapper , had sudo pip install virtualenvwrapper , running code in bash not find unless did

export workon_home=$home/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh 

so did research , think can permanatly add them 'bash profile'. if case have 2 questions.

  1. is there way can avoid having manually add exports in first place. can have commands working right after installing
  2. how add them profile. opened .bash_profile.swp , looked intimidating didn't touch because thought i'd break it. i'm not sure why had random pathing psycopg2 @ end of line either( seen in second link) http://imgur.com/jedeon9 http://imgur.com/cysgvmx

you correct. adding these .bash_profile set environment variables every time start shell. however, explained here, better put them in .bashrc , source .bash_profile. example,

# put in .bashrc path="/applications/postgres.app/contents/versions/9.4/bin:$path" export database_url="postgresql://localhost/cheese" export app_settings="config.developmentconfig" # etc...  # put in .bash_profile if [ -f ~/.bashrc ];    source ~/.bashrc fi 

this ensures variables set no matter how start shell. .swp file seeing created vim. ignore it.

however, there better way. easiest , cleanest way install software on computer package manager, automatically set paths (among other things). mac, recommend using homebrew. once install it, can things like

$ brew install ruby $ ruby blah blah blah  # ruby gets put in path you! 

for python, standard package manager pip, using. however, word of advice: sudo pip installs packages python 2 comes part of os x, personal experience recommend not doing. instead, install python 2 homebrew, , use pip (and python) comes that.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -