How to set pyenv python for reticulate - r

I'm using 1.10 version of reticulate package ( R version is 3.5.1) and I want to configure it to use pyenv python (path is /Users/name/.pyenv/versions/hak/bin/python). Running py_config() won't show me this python as available:
python: /usr/bin/python
libpython:
/System/Library/Frameworks/Python.
framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome:
/System/Library/Frameworks/Python.
framework/Versions/2.7:/System/Library
/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/ Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
python versions found:
/usr/bin/python
/usr/local/bin/python
/usr/local/bin/python3
Because my pyenv python isnt available I set RETICULATE_PYTHON env variable on mentioned path. But now i get the error
Error in initialize_python(required_module, use_environment) :
Python shared library
'/Users/name/.pyenv/versions/3.6.5/lib/libpython3.6.dylib'
not found, Python bindings not loaded.
Does anybody know how to solve this ?

pyenv doesn't build pythons with shareable libraries by default. to make sure it does either have the CONFIGURE_OPTIONS variable set or preface your pyenv build $VERSION commands as in the example below:
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.5
see:
https://github.com/pyenv/pyenv/blob/master/plugins/python-build/README.md#building-with---enable-shared)

Related

Installation of TensorFlow not found in Rstudio (on Mac)

I am new to TensorFlow and Keras and I installed them in Rstudio using a conda virtual environment. I run the following line and everything works.
library(reticulate)
use_condaenv("r-reticulate")
library(tensorflow)
library(keras)
However when I try to call the function "keras_model_sequential()" I get this error:
**Error: Python module tensorflow.keras was not found.
Detected Python configuration:
python: /anaconda3/envs/r-reticulate/bin/python
libpython: //anaconda3/envs/r-reticulate/lib/libpython3.6m.dylib
pythonhome: /anaconda3/envs/r-reticulate:/anaconda3/envs/r-reticulate
version: 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 18:53:43) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: /anaconda3/envs/r-reticulate/lib/python3.6/site-packages/numpy
numpy_version: 1.19.2
tensorflow: /anaconda3/envs/r-reticulate/lib/python3.6/site-packages/tensorflow
python versions found:
/anaconda3/envs/r-reticulate/bin/python
/usr/bin/python
/anaconda3/envs/covid19/bin/python
/anaconda3/envs/test/bin/python
/anaconda3/envs/test2/bin/python
**
What should I do? I am using a Mac with El Capitan (version 10.11.6). Thank you very much Riccardo

Error: ModuleNotFoundError: No module named 'keras' when using keras in R

I have a problem running Keras in R. When running mnist <- dataset_mnist() I get the error Error: ModuleNotFoundError: No module named 'keras'
I have installed the most recent version of Anaconda, I am running R version 3.5.1 in RStudio 1.1.463. In R I have run
library("keras")
install_keras()
and this succeeds.
When trying to run mnist <- dataset_mnist() I initially got the following error message:
ImportError: No module named keras
Use the install_keras() function to install the core Keras library
Error: Error loading Python module keras
When running
library(reticulate)
py_config()
I got the following output:
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
keras: [NOT FOUND]
After looking at suggested solutions to other topics, I added this line to my .Rprofile
Sys.setenv(RETICULATE_PYTHON = "/anaconda3/envs/r-tensorflow/bin")
However when I run mnist <- dataset_mnist() now I get the following error:
Error: Python module keras was not found.
Detected Python configuration:
python: /anaconda3/envs/r-tensorflow/bin/python
libpython: /anaconda3/envs/r-tensorflow/lib/libpython3.6m.dylib
pythonhome: /anaconda3/envs/r-tensorflow:/anaconda3/envs/r-tensorflow
version: 3.6.7 | packaged by conda-forge | (default, Nov 20 2018, 18:37:09) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: [NOT FOUND]
keras: /anaconda3/envs/r-tensorflow/lib/python3.6/site-packages/keras
NOTE:
Does anyone know what I can do to solve this?

error of python module for docker and splashr

I have installed docker and image of splash by
docker pull scrapinghub/splash
and started the container by
docker run -p 8050:8050 -p 5023:5023 scrapinghub/splash
which its result can be seen in the picture below
but, the problem is that in R after running install_splash() I receive this error:
Error: Python module docker was not found.
Detected Python configuration:
python: C:\Users\m-joudy\AppData\Local\Programs\Python\Python36\\python.exe
libpython: C:/Users/m-joudy/AppData/Local/Programs/Python/Python36/python36.dll
pythonhome: C:\Users\m-joudy\AppData\Local\Programs\Python\Python36
version: 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]
Architecture: 64bit
numpy: [NOT FOUND]
docker: [NOT FOUND]
python versions found:
C:\Users\m-joudy\AppData\Local\Programs\Python\Python36\\python.exe
C:\Users\m-joudy\AppData\Local\Programs\Python\PYTHON~1\\python.exe
From splashr's README we learn that the docker commands you used and install_splash() are alternatives, i.e. after
docker pull scrapinghub/splash
docker run -p 8050:8050 -p 5023:5023 scrapinghub/splash
you should be ready to use
library(splashr)
splash_active()
and be set to use splash via splashr. If you still want to make install_splash() work, then the error message you quoted tells us, that the python modules docker and numpy are missing. How you install python packages depends on your installation, but one poular way is to use pip, i.e.
pip install numpy
pip install docker
Potentially within a virtual environment.

Not able to execute embedded Saltstack state using gitfs

I am working with the "gitfs" feature of SaltStack in order to execute a state file.
The state file uses the "include" feature to embed other two state files from the repository.
My repository has the following hierarchy:
salt
- dir1
- dir3 / init.sls
- dir4 / init.sls
- dir2
- dir5 / init.sls
My master file is as below:
. . .
fileserver_backend:
- git
gitfs_remotes:
- https://username#bitbucket.org/path/to/repo.git
. . .
The salt/dir1/dir3/init.sls contains the following:
include:
- salt/dir2/dir5/init.sls
- salt/dir1/dir4/init.sls
. . .
On restarting salt-master and then executing
salt-run fileserver.file_list saltenv=base backend=git
shows me all the files from the repository.
But on running
salt '' state.apply salt.dir1.dir3 -l debug
I am getting the following error:
[ERROR ] Data passed to highstate outputter is not a valid highstate return: {'<minion-id>': ['Specified SLS salt/dir2/dir5/init.sls in saltenv base is not available on the salt master or through a configured fileserver', 'Specified SLS salt/dir1/dir4/init.sls in saltenv base is not available on the salt master or through a configured fileserver']}
My system configurations are as follows:
$ salt --versions-report
Salt Version:
Salt: 2016.3.3
Dependency Versions:
cffi: Not Installed
cherrypy: 3.2.2
dateutil: 1.5
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 0.9.1
msgpack-pure: Not Installed
msgpack-python: 0.3.0
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
python-gnupg: Not Installed
PyYAML: 3.10
PyZMQ: 14.0.1
RAET: Not Installed
smmap: 0.8.2
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: Ubuntu 14.04 trusty
machine: x86_64
release: 3.13.0-91-generic
system: Linux
version: Ubuntu 14.04 trusty
The repository gets cached into the "/var/cache/salt/master/gitfs/refs/base/salt" path on restarting salt-master.
But I found "dir2/dir5/init/sls" instead of "dir2/dir5/init.sls"
What could be the reason for this issue?
The issue is most likely in your include declaration. Salt's include module treats SLS files similar to Python modules. For example, you would reference a SLS file foo/bar/baz.sls as foo.bar.baz.
Also, the init.sls file receives special treatment and enables you to treat an entire directory as a module. For example, foo.bar.baz would include either foo/bar/baz.sls or foo/bar/baz/init.sls (depending on which of them actually exists).
In conclusion, your include statement should look like this:
include:
- salt.dir2.dir5
- salt.dir1.dir4

How to install Julia in an anaconda environment?

One of the main features of Anaconda is that it is language agnostic as stated in their blog:
You can create environments of any binary dependency tree (different
versions of Python, R, Julia, etc.).
Recently I switched from using virtualenv to Anaconda in Python, so I was curious to try Julia in an Anaconda environment. However, I couldn't find instructions explicit enough to install Julia successfully. First, I tried naively conda create -n julia-test julia. Obviously, it didn't work. Then I found at binstar.org a Julia package (version 0.3) with the code
conda install -c https://conda.binstar.org/wakari1 julia
However, I don't want to install Julia outside of a specific virtual environment, so I changed it to:
conda create -n julia-test -c https://conda.binstar.org/wakari1 julia
It didn't throw errors but ultimately failed to start the Julia interpreter.
So, what is the correct way of installing Julia (0.2, preferably) in an anaconda environment?
UPDATE
As of March 2018, Julia v0.6.1 is available for linux-64 on the conda-forge channel:
https://anaconda.org/conda-forge/julia
It has been set up to install packages inside <env_prefix>/share/julia/site, to maintain isolation from the user's ~/.julia user's home directory.
conda create -n julia -c conda-forge julia
As of August 2017, Julia v0.5.2 is available on the conda-forge channel:
https://anaconda.org/conda-forge/julia
It has been set up to install packages inside <env_prefix>/share/julia/site, to maintain isolation from the user's ~/.julia user's home directory.
conda create -n julia -c conda-forge julia
The blog post was indicating that conda is general enough to allow packages of any type. There are no packages for Julia yet (except for the one you found in the Wakari channel, which is specific to Wakari).
Building a conda package for Julia and probably isn't difficult. Building a streamlined way to convert Julia packages into conda packages is a bit more work.
Julia 0.4.5 (not the current latest 0.5.0) is now available from the bioconda channel.
Using anaconda (python 3.6 version) and following instructions in bioconda :
# In this order
conda config --add channels conda-forge
conda config --add channels defaults
conda config --add channels r
conda config --add channels bioconda
conda install julia
So to create the corresponding virtual environment:
conda create -n julia-env julia
Nonetheless, I did not see any additional julia libraries available yet.
As of Jan 2022, Anaconda suggests using;
conda install -c conda-forge julia
See: https://anaconda.org/conda-forge/julia

Resources