Reputation: 2393
I recently downloaded nltk_data in Macintosh HD 2 (Renamed "External") since my main HD is out of memory, can someone help me in setting environment variables for the same? I tried the following in my .bash_profile however it just runs temporarily till bash runs, I need to make the change permanent:
PATH="$/Volumes/External/bin:$PATH"
export PATH
Upvotes: 2
Views: 1629
Reputation: 50220
Setting environment variables on OS X is a bit tricky, and it's a moving target: Stackoverflow is full of good solutions that no longer work.
If your goal is to use the nltk from programs or applications that you launch from Terminal, then it's pretty straightforward; in your .bash_profile
or .bashrc
, set and export the required variables.
If you have trouble launching the right Python or idle
executable, add the directory that contains them to your PATH
variable pretty much as you show in your question. (But the first $
you show is a mistake: This path is not a shell variable).
export PATH="/Volumes/External/bin:$PATH"
To allow the nltk to find the corpora and resources you downloaded with nltk.download()
, set the NLTK_DATA
variable. E.g.,
export NLTK_DATA=/Volumes/External/nltk_data
It looks like your question was answered by the second bullet, but I give both since it's not always clear (to new users) which one is relevant.
Be aware that applications you launch from the Launchpad (e.g., the Anaconda launcher) will not be able to see variables you set in this way. That is a more complicated problem to solve, as mentioned above, and as far as I know there is no solution that will work for all applications in recent OS X versions. Just launch your python application or IDE from the command line (by typing idle
, subl
etc. at the bash prompt), and you'll be all right.
Upvotes: 2
Reputation: 2096
Do you need to get access to NLTK taggers and dicts? There is a way to extend NLTK path (it is a simple list):
import nltk
nltk.path.append('/home/to/some_path/nltk_data/')
Upvotes: 0