r - knitr - error when importing python module -


i having trouble when running python engine in knitr. can import modules not others. example can import numpy not pandas.

{r, engine='python'} import pandas

i error.

quitting lines 50-51 (prepayment.rmd)  error in (knit_engines$get(options$engine))(options) :  traceback (most recent call last): file "<string>", line 1, in <module> importerror: no module named pandas calls: <anonymous> ... process_group.block -> call_block -> block_exec -> in_dir -> <anonymous> in addition: warning message: running command ''python'  -c 'import pandas' 2>&1' had status 1  execution halted 

it must system path , pointing.

normally in ipython use

import sys sys.path.append('/path/to/directory/') 

to add paths. don't know problem is.

for reason works little different in ipython

the following worked me.

i first went ipython , did following

import pandas import os path = os.path.dirname(pandas.__file__) out[4]: '/users/glendonthompson/anaconda/lib/python2.7/site-packages/pandas' 

then in rstudio in .rmd file ran

```{r, engine='python'} import sys sys.path.append('/users/glendonthompson/anaconda/lib/python2.7/site-packages/') import pandas ``` 

maybe anaconda messing packages....

is true knitr using python engine have cache otherwise won't retain code in previous chunks?

```{r, engine='python'} import sys sys.path.append('/users/glendonthompson/anaconda/lib/python2.7/site-packages/') ```  ```{r,engine = 'python'} import pandas ``` 

doesn't work....


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -