conda和java,如何在Jupyter Notebook内部的conda环境中使用特定的Java版本

My overall aim is to use sparklyr within an R Jupyter notebook on my Azure cloud service of Jupyter lab. I created a new conda environment with R, sparklyr and Java 8 (since this is the version supported by sparklyr) as follows:

conda create -n r_spark r=3.6 r-essentials r-irkernel openjdk=8 r-sparklyr

source activate r_spark

R

> IRkernel::installspec(user=TRUE, name="rspark", displayname="R (Spark)")

When I run R within a terminal session within this environment, everything works fine:

R

> system("java -version")

openjdk version "1.8.0_152-release"

OpenJDK Runtime Environment (build 1.8.0_152-release-1056-b12)

OpenJDK 64-Bit Server VM (build 25.152-b12, mixed mode)

> library(sparklyr)

> sc

* Using Spark: 2.3.3

Registered S3 method overwritten by 'openssl':

method from

print.bytes Rcpp

> spark_disconnect(sc)

NULL

>

However, when I do the same within a notebook with the very same "R (Spark)"-kernel, it uses Java openjdk version 11:

library(sparklyr)

sc

Error in validate_java_version_line(master, version): Java version detected

but couldnt parse version from: openjdk version "11.0.4" 2019-07-16

Traceback: [...]

Furthermore system("java -version", intern=TRUE) returns an empty result from within the notebook.

How can I tell the notebook to use the Java version from its environment?

解决方案

@merv's comment put me on the right track:

Get the current JAVA_HOME-path with Sys.getenv("JAVA_HOME") in the R console in the terminal within the environment: "/path/to/your/java".

In the notebook with the corresponding environment kernel, use Sys.setenv(JAVA_HOME="/path/to/your/java") and go!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值