I want to create an exe of my Python script without including the Python environment and its packages using pyinstaller. The system running the exe file already has the python environment and all the packages installed.
I tried excluding a few packages by using the exclude command but not able to find any ways to exclude the python environment.
Related
First time question asker.
I created an Excel/R tool that uses:
Excel VBA to create a CSV file with data for R,
Launch R using a Windows Shell,
Detects when R is finished running and then
Imports the results in a CSV file created by the R script.
Unfortunately, the R code does not work as programed with some package versions created after 3/1/2020, which creates problems for new users because they cannot just install the current package versions or users who want to use conflicting versions for other projects.
I have a solution for users who do not require newer versions of R for their other work; writing a script that installs all the packages and their dependents using the “versions” package. However, I think this approach will constrain users who want to use newer versions of R. **Is this a correct assumption? **
I thought the {checkpoint} package might offer a good solution. I can get it to run in well in RStudio by creating a RStudio project (where I ran the {checkpoint} package to install the 3/1/2020 versions of my packages). However, I have not found a way to run the R script from the Windows Shell. The R script does not seem to be able to access the packages installed in the RStudio project using {checkpoint}. Does anyone have ideas of how I can have Excel VBA launch the start of the R script in a way that it can assess the packages installed in the RStudio project by {checkpoint}? Perhaps there is a Windows Shell call for RStudio similar to the one I use now for R?
Here is the Windows Shell code I currently use for R in case it helps. It works with the versions approach but not the {checkpoint} approach.
rExeCall = "C:\Program Files\R\R-3.6.2\bin\Rscript.exe"
rExeOptns = " --no-environ --no-init-file --no-restore --verbose "
rscrpt=”Tool.R”
Shell (rExeCall & rExeOptns & rscrpt)
Thank you in advance for your help!
I had hoped that my current R shell code would work when I used {checkpoint} to install the correct versions of the packages in an RStudio project.
I tried specifying the .libPaths to the file location for the RStudio projection (per Running R script from PHP in VSCode not recognizing R packages) without success.
I want to use Anaconda to provide separate isolated environments, each with different combinations of r-packages. If this was Python, I would specify an environment .yml file with Python Anaconda packages where those exist, and pip-ones for those that are not in Anaconda.
For R, a similar situation exist, some R packages are not in Anaconda. If I do install.packages("package_name") the packages end up in my user homedir (on windows in Documents/R/win-library...). This is not ideal, because these installed packages are not confined within the Anaconda environment and can be seen from all Anaconda environments.
Two questions:
How can I specify these (non-Anaconda r-packages) in the environment .yml file, if possible?
How can I install non-Anaconda r-packages so they are confined within an Anaconda environment.
In summary, I want to achieve environent isolation for R in the same manner it is achived with Python.
Regards Niels Jespersen
I want to create a new R environment using anaconda. Following this page 'https://docs.anaconda.com/anaconda/user-guide/tasks/using-r-language/' I created an environment called eeEnv_r using this command in anaconda prompt conda create -n r_env r-essentials r-base. However the environment that was created looks like it was python environment. But when I type conda list I see some r packages such as dplyr appearing in addition to some python packages. Also there is python.exe file in environment folder. Any ideas why this is ?
I am trying to use VS code to run R, since I am familier with the IDE (used for python work). Also I want to create environments in R and then use those environment ins VS code (similar to python).
r-base depends on glib``notebook, which depends on python, therefore installing the latest r-base package will always pull in a python interpreter as well.
I would look at this from a different angle: with conda there is no such thing as a python or r-environment environments can mix packages from various languages. For most use cases this should not be a problem.
I am writing an R package that needs to include an executable file (“mod.exe” in Windows environments or “mod” in Unix environments). One of the R functions in the package makes a call to the system that calls the executable as follows:
system(paste("mod", …))
Since CRAN will not accept packages with binary codeand because I would like the package to be portable to both Window and Unix systems, I would like to be able to just include the C source (“.h” and “.c”) files that can be used to build the executable “mod” in the source package. Ideally, when a user installs the R package, the source files should be compiled (with a C compiler available through Rtools on Windows or through a native C compiler on Unix) to create the executable “mod” during installation. Then, ideally, the executable “mod” would be stored in the binary package so that the aforementioned R function can call “mod” directly. (The .h and .c files have already been written so I do not want to rewrite or modify them.)
I've read http://r-pkgs.had.co.nz/package.html, looked through https://cran.r-project.org/doc/manuals/r-release/R-exts.html, and tried to find packages on CRAN that have already done something like what I’ve proposed, but haven’t been successful. I I attempted to solve my problem by putting all the C source files for “mod” into a /src directory in the source package along with a working makefile in the hope that this would cause the building of “mod” when the package was built and cause it to be stored somewhere in the binary package so that the R function could call “mod”. However, this did not work and when I try to look into the binary package the only thing I can see that was created is a /libs folder containing /i386 and /x64 folders, which both contain a dynamic linked library (on Windows, “RMCSim.dll”)-- I do not know what to do with this DLL.
If I create a version of the package in which the executable “mod” is placed into a package directory called “exec”, the R function can call the “mod” function. Unfortunately, this solution (1) is not portable to both Windows and Unix environments and (2) leads to a package that cannot be accepted by CRAN.
Please respond if you have any ideas for how to approach this problem or if you know of any examples of packages that do something similar with C source code. Thanks!
I have installed MLFLOW for R in my ubuntu environment. When I try to execute any command for mlflow I am getting below error
mlflow_ui()
Error in rethrow_call(c_processx_exec, command, c(command, args), stdin, :
cannot start processx process (system error 2, No such file or directory) #unix/processx.c:573
You can install MLFlow separately using pip and then specify the variables in your ~/.Renviron. If you don't have a .Renviron file, create one. (Checkout out help("Startup") in R for more info).
The environment variables you need to set in the .Renviron file are:
MLFLOW_PYTHON_BIN and MLFLOW_BIN. These need to set to the location of your python executable and mlflow executable.
Simply get those by running which python and which mlflow after installing mlflow with pip.
Make sure to restart Rstudio (perhaps try removing mlflow and re-installing the package).
Then there will be no need to run mlflow::install_mlflow().
#digvijay have you installed conda & invoked the R install_mlflow function on your machine? It's necessary to do so before invoking the R APIs - install_mlflow creates a conda environment for installing the MLflow CLI, which some of the R APIs (e.g. mlflow_ui) depend on.