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
pathvariable process viasys.setenv(as have done):sys.setenv(path="/anaconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games") system("python in_tag_main_model/python_scripts/connect_to_couchbase.py")use newer
system2function providesenvargument 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/bin:/sbin:/bin:/usr/games")note
system2has different calling conventionsystem.
Comments
Post a Comment