[Rd] Robust, platform independent method to check for python

Steve Weston steve at revolution-computing.com
Sat Jun 27 19:51:16 CEST 2009


You can also try to find Python on Windows machines by
reading the registry using the R readRegistry function (added
sometime around R 2.7.0, I think).  You can't count on the
information being there, but it often is, depending on how
Python was installed.

Using the registry seems to work better than using PATH,
since the standard Python installer doesn't update PATH,
although the ActiveState Python installer does.  But both
approaches can fail, depending on the options that were
specified when Python was installed.

Good luck,

- Steve


On Sat, Jun 27, 2009 at 12:01 PM, Gabor
Grothendieck<ggrothendieck at gmail.com> wrote:
> If you can assume its on your path then try this:
>
> pth <- sapply(strsplit(Sys.getenv("PATH"), ";"), function(x)
> file.path(x, "python.exe", fsep = "\\"))
> pth[file.exists(pth)][1]
>
> On Sat, Jun 27, 2009 at 11:44 AM, Carlos J. Gil
> Bellosta<cgb at datanalytics.com> wrote:
>> Hello,
>>
>> I have been unsuccessfully struggling for a programmatical method to
>> find out whether and where Python is installed.
>>
>> The reason is that I am developing a package that depends on python.
>>
>> On UNIX/UNIX-like systems I can quite safely assume that python is
>> directly callable via system if installed.
>>
>> My main problems is Windows, though...
>>
>> Has anybody faced this problem before?
>>
>> Best regards,
>>
>> Carlos J. Gil Bellosta
>> http://www.datanalytics.com
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Steve Weston
REvolution Computing
One Century Tower | 265 Church Street, Suite 1006
New Haven, CT  06510
P: 203-777-7442 x266 | www.revolution-computing.com



More information about the R-devel mailing list