Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

r - reticulate py_run_file() function can't execute python script

Why am I getting this error???

I am using pyenv virtualenv in wich I have started R

> library(reticulate)
> py_discover_config()
python:         /home/zvuser/.pyenv/shims/python3
libpython:      /home/zvuser/.pyenv/versions/3.7.5/lib/libpython3.7m.so
pythonhome:     /home/zvuser/.pyenv/versions/zvpjct:/home/zvuser/.pyenv/versions/zvpjct
version:        3.7.5 (default, Jan 26 2021, 19:47:35)  [GCC 7.5.0]
numpy:          /home/zvuser/.pyenv/versions/3.7.5/envs/zvpjct/lib/python3.7/site-packages/numpy
numpy_version:  1.19.5

python versions found:
 /home/zvuser/.pyenv/shims/python3
 /usr/bin/python3
 /usr/bin/python

> py<-import_main()
> py$var1=1
> py$var2=2
> py_run_file('blah.py')
Error in py_run_file_impl(file, local, convert) :
  IndexError: list index out of range

Detailed traceback:
  File "<string>", line 3, in <module>

Here is the python script:

cat blah.py

from sys import argv

var1=argv[1]
var2=argv[2]
vzv=var1+var2
print(vzv)

What is wrong with this code. I am running of ideas. I tried use_python('/home/zvuser/.pyenv/versions/3.7.5/bin/python3.7') no difference.

question from:https://stackoverflow.com/questions/65912147/reticulate-py-run-file-function-cant-execute-python-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...