2

I want to use a python engine in knitr. I have installed a module named undaqTools for python 2.7 using Anaconda3. If I run the following in IPython, it works fine:

from undaqTools import Daq

I tried the same in a python code chunk but that didn't work. I found a relevant question in SO, linked here. So, I first did following in IPython:

import undaqTools
import os
path = os.path.dirname(undaqTools.__file__)
path
Out[5]: 'C:\\Anaconda3\\envs\\py27\\lib\\site-packages\\undaqtools-0.2.3-py2.7.egg\\undaqTools'  

Therefore, I created a new chunk in knitr and did following:

```{python}
import sys
sys.path.append('C:/Anaconda3/envs/py27/lib/site-packages/undaqtools-0.2.3-py2.7.egg/')
from undaqTools import Daq
```  

But that gives me following error:

Traceback (most recent call last):
  File "C:\Users\durraniu\AppData\Local\Temp\RtmpGOOQHX\chunk-code195061e728da.", line 13, in <module>
    from undaqTools import Daq
  File "C:\Anaconda3\envs\py27\lib\site-packages\undaqtools-0.2.3-py2.7.egg\undaqTools\__init__.py", line 5, in <module>
ImportError: No module named 'daq'  

How can I fix this?

Community
  • 1
  • 1
umair durrani
  • 5,597
  • 8
  • 45
  • 85
  • 1
    @yihui Thanks for your edit. This error is resolved now. The problem was not with `knitr` but with `Anaconda` Python distribution. I think Anaconda creates its own environment which was not somehow *connected* with other file systems of the Windows. So, I uninstalled Anaconda and installed Python from official website. Then I installed all the `undaqtools` package and dependencies using `pip` and added everything to Windows system and user PATH variables. Afterwards, when I ran the code in `rmarkdown`, it ran without any error. – umair durrani Oct 16 '16 at 18:25

0 Answers0