Closed erickrf closed 6 years ago
Thanks for the bug report. Confirm the bug when I use Python 2. but the bug goes away when I instruct the findpython
package to use Python 3. instead. Python 3.* added better Unicode handling compared to the older Python versions. Agree that that error message isn't very helpful at all.
I'll try to patch the package (or maybe the findpython
package) to at least check if there are 3.2+ versions of Python before falling back to Python 2.5-2.7 but in the meantime depending on your specific environment you could probably get your parser working by adding something like options(python_cmd="python3")
before the parser$parse_args()
call in your Rscript:
trevorld@stoic-sloth:~/tmp$ cat test.R
options(python_cmd= "python3")
suppressPackageStartupMessages(library("argparse"))
p = ArgumentParser()
p$add_argument("name")
args = p$parse_args()
print(args$name)
trevorld@stoic-sloth:~/tmp$ Rscript test.R 毛泽东
[1] "毛泽东"
trevorld@stoic-sloth:~/tmp$
I see, thanks for the workaround!
Outline of what i plan to do:
1) Update R code to search for Python 3.2+ first and then try earlier versions of Python 2) Update INSTALL about needing higher Python version if application needs to support Unicode arguments/options. 3) Update R code to provide a better error message (instructing them they might need a higher Python version and to see INSTALL for more details)
I have found an error when reading command line input with non-ascii characters. To be honest, the error message wasn't helpful at all and cost me a while to find what was wrong: