pyConnect: connects R to Python

Description Usage Arguments Details Note Examples

View source: R/PythonInR.R

Description

Connects R to Python. (The parameters are only needed for the Windows version!)

Usage

1
2
3
4
pyConnect(pythonExePath = NULL, dllDir = NULL, pythonHome = NULL)

pyConnectWinDll(dllName, dllDir, majorVersion, pythonHome, pyArch,
  useCstdout = NULL)

Arguments

pythonExePath

a character containing the path to "python.exe" (e.g. "C:\Python27\python.exe")

dllDir

an optional character giving the path to the dll file. Since the dll file is normally in a system folder or in the same location as python.exe, this parameter is almost never needed!

pythonHome

an optional character giving the path to PYTHONHOME. On Windows by default PYTHONHOME is the folder where python.exe is located, therefore this parameter is normally not needed.

dllName

a character giving the name of the dll file (e.g.d "python27.dll").

majorVersion

an integer giving the major Python version (e.g. 2 or 3).

pyArch

a character giving the Python architecture, i.e. "32bit" or "64bit".

useCstdout

a logical indicating if the C stdout should be used or the stout should be redirected at a Python level.

Details

There is a different behavior for the static (Linux default) and the explicit linked (Windows default) version. Where as the static linked version automatically connects, when the package get's loaded, the explicitly linked version needs to be connected manually. More information can be found at the README file or at http://pythoninr.bitbucket.org/.

Note

See the README for more information about the Windows setup.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
## Linux examples
pyConnect() # is done by default when the package is loaded

## Windows examples
pyConnect() ## will try to detect a suitable python version 
            ## from the PATH given in the environment variables
pyConnect("C:\\Python27\\python.exe")

## One can also explicitly set the parameters for the connection.
PythonInR:::pyConnectWinDll(dllName="python27.dll", dllDir=NULL,
                            majorVersion=2, pythonHome="C:\\Python27", 
                            pyArch="32bit")

## End(Not run)

Example output

Initialize Python Version 2.7.6 (default, Nov 23 2017, 15:53:45) 
[GCC 4.8.4]

R is already connected to Python!
R is already connected to Python!
R is already connected to Python!
R is already connected to Python!
NULL

PythonInR documentation built on July 1, 2020, 6:05 p.m.