system commant wont work as in shell when calling a python comman on Ubuntu from R -


i'm trying invoke within r system command invokes call python script (that includes import pandas) following:

getwd() [1] "/home/production" > system("python in_tag_main_model/python_scripts/connect_to_couchbase.py") traceback (most recent call last):   file "in_tag_main_model/python_scripts/connect_to_couchbase.py", line 11, in <module>     import pandas pd importerror: no module named pandas 

within connect_to_couchbase.py i'm calling pandas, isn't recognized, though when i'm running exact command machines shell:

production@va-rsrv01:~$ python in_tag_main_model/python_scripts/connect_to_couchbase.py production@va-rsrv01:~$ 

it works great,any ides why system isn't working me?

thanks in advance!

it looks r system function executing different python executable. have 3 options specify executable want:

  • you absolute path:

    system("/anaconda2/bin/python in_tag_main_model/python_scripts/connect_to_couchbase.py") 
  • set path variable process via sys.setenv (as have done):

    sys.setenv(path="/anaconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bi‌​n:/sbin:/bin:/usr/games") system("python in_tag_main_model/python_scripts/connect_to_couchbase.py")  
  • use newer system2 function provides env argument can used modify environmental variables subprocess:

    system2("python",         args="in_tag_main_model/python_scripts/connect_to_couchbase.py",         env="path=/anaconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bi‌​n:/sbin:/bin:/usr/games") 

    note system2 has different calling convention system.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -