I am trying to use rPython to import some of the nltk functionality into my R program. My test function is,
test.py
import random, numpy,nltk
import sys
print (sys.version)
number = random.randint(1, 1000)
print(number)
string = nltk.word_tokenize('home sweet home')
print(string)
Running the code from console it runs fine,
python test.py
2.7.10 (default, Sep 23 2015, 04:34:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)]
331
['home', 'sweet', 'home']
Running from R however, I am encountering this problem,
library(rPython)
python.load("test.py")
Error in python.exec(code, get.exception) : No module named nltk
same with RStudio. If I remove "nltk" then things work fine,
python.load("test.py")
2.7.10 (default, Aug 22 2015, 20:33:39)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)]
386
Seems both of them using the same version of python 2.7 I see this user having a similar issue but only with RStudio. RStudio doesn't load all Python modules via rPython call