在 Julia 上只安装一个包 [英] Install just one package globally on Julia

查看:18
本文介绍了在 Julia 上只安装一个包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台机器上安装了新的 Julia,我想将它用作实验室中不同人员的数字处理服务器.似乎有一个名为 jupyterhub 的不错的包,它使 Jupyter Notebook 界面同时可供各种客户端使用.一个我再也找不到的网页开始建议首先全局安装 IJulia,然后安装 JupyterHub..."

我似乎找不到一种全局安装 ONE 软件包的好方法.

解决方案

更新

在 Julia-v0.7+ 中,我们需要使用 JULIA_DEPOT_PATH 而不是 JULIA_PKGDIR 并且 LOAD_PATH 看起来像这样:

朱莉娅>加载路径三元素数组{Any,1}:Base.CurrentEnv()Any[Base.NamedEnv("v0.7.0"), Base.NamedEnv("v0.7"), Base.NamedEnv("v0"), Base.NamedEnv("default"), Base.NamedEnv("v0.7", 创建=真)]/Users/gnimuc/Codes/julia/usr/share/julia/stdlib/v0.7"

旧帖

<块引用>

先全局安装 IJulia,再安装 JupyterHub..."

不知道是真是假,按照下面这些步骤,你可以在安装Jupyterhub之后安装IJulia.

为每个用户在系统范围/全局范围内安装软件包

Stefan 已在此处回答了这个问题卡尔平斯基.所以我们只需要使用这个方法来安装 IJulia.jl 包.

<块引用>

有一个名为 LOAD_PATH 的 Julia 变量被安排指向您的 julia 安装下的两个系统目录.例如:

朱莉娅>加载路径2 元素数组{Union(ASCIIString,UTF8String),1}:/opt/julia-0.3.3/usr/local/share/julia/site/v0.3"/opt/julia-0.3.3/usr/share/julia/site/v0.3"

<块引用>

如果您在其中任何一个目录下安装软件包,那么使用该 Julia 的每个人都会看到它们.一种方法是在 shell 中执行 export JULIA_PKGDIR=/opt/julia-0.3.3/usr/share/julia/site 后,以可以写入这些目录的用户身份运行 julia.这样 Julia 将使用它,因为它是包目录,而普通的包命令将允许您为每个人安装包......

让 IJulia 与 Jupyterhub 合作

为了使 IJuliaJupyterhub 为所有用户相互协作,您应该复制文件夹 your/user/.local/share/jupyter/kernels/julia//usr/local/share/jupyter/kernels/.我写下了我在测试中使用的一些步骤 Dockerfile.代码很丑,但它可以工作.

步骤:(成功安装 Jupyterhub 后)

请注意,您应该以 root 身份执行以下步骤,并且我假设您的 julia 已全局安装在 /opt/julia_0.4.0/.

  1. 制作我们的全局包目录并设置JULIA_PKGDIR:

    mkdir/opt/global-packagesecho 'push!(LOAD_PATH, "/opt/global-packages/.julia/v0.4/")' >>/opt/julia_0.4.0/etc/julia/juliarc.jl出口 JULIA_PKGDIR=/opt/global-packages/.julia/

  2. 使用包管理器安装IJulia":

    julia -e 'Pkg.init()'julia -e 'Pkg.add("IJulia")'

  3. kernelspecs复制到/usr/local/share/jupyter/kernels/Jupyterhub添加的任何新用户都可以使用它/代码>:

    jupyter 内核规范列表cd/usr/local/share/&&mkdir -p jupyter/内核/cp -r/home/your-user-name/.local/share/jupyter/kernels/julia-0.4-your-julia-version/usr/local/share/jupyter/kernels/

I have a fresh Julia instalation on a machine that I want to use as a number-crunching server for various persons on a lab. There seems to be this nice package called jupyterhub wich makes the Jupyter Notebook interface avaible to various clients simultaneusly. A web page which I am unable to find again began suggesting something like "first install IJulia globally, then install JupyterHub..."

I cannot seem to find a nice way to install ONE package globally.

解决方案

Update

In Julia-v0.7+, we need to use JULIA_DEPOT_PATH instead of JULIA_PKGDIR and the LOAD_PATH looks something like this:

julia> LOAD_PATH
3-element Array{Any,1}:
 Base.CurrentEnv()                                                                                                                     
 Any[Base.NamedEnv("v0.7.0"), Base.NamedEnv("v0.7"), Base.NamedEnv("v0"), Base.NamedEnv("default"), Base.NamedEnv("v0.7", create=true)]
 "/Users/gnimuc/Codes/julia/usr/share/julia/stdlib/v0.7" 

Old Post

"first install IJulia globally, then install JupyterHub..."

I don't know whether this is true or not, by following these steps below, you can install IJulia after you installed Jupyterhub.

Install packages system-wide/globally for every user

this question has already been answered here by Stefan Karpinski. so what we need is just use this method to install the IJulia.jl package.

There's a Julia variable called LOAD_PATH that is arranged to point at two system directories under your julia installation. E.g.:

julia> LOAD_PATH
2-element Array{Union(ASCIIString,UTF8String),1}:
 "/opt/julia-0.3.3/usr/local/share/julia/site/v0.3"
 "/opt/julia-0.3.3/usr/share/julia/site/v0.3"

If you install packages under either of those directories, then everyone using that Julia will see them. One way to do this is to run julia as a user who can write to those directories after doing export JULIA_PKGDIR=/opt/julia-0.3.3/usr/share/julia/site in the shell. That way Julia will use that as it's package directory and normal package commands will allow you to install packages for everyone....

Make IJulia working with Jupyterhub

in order to make IJulia and Jupyterhub working with each other for all the users, you should copy the folder your/user/.local/share/jupyter/kernels/julia/ to /usr/local/share/jupyter/kernels/. I write down some of the steps that I used in my test Dockerfile. the code is ugly, but it works.

Steps: (after you successfully installed Jupyterhub)

note that, you should do the following steps as root and I assume that your julia was globally installed at /opt/julia_0.4.0/.

  1. make our global package directory and set up JULIA_PKGDIR:

    mkdir /opt/global-packages
    echo 'push!(LOAD_PATH, "/opt/global-packages/.julia/v0.4/")' >> /opt/julia_0.4.0/etc/julia/juliarc.jl
    export JULIA_PKGDIR=/opt/global-packages/.julia/
    

  2. install "IJulia" using package manager:

    julia -e 'Pkg.init()'
    julia -e 'Pkg.add("IJulia")'
    

  3. copy kernelspecs to /usr/local/share/jupyter/kernels/ which can be used by any new user added by Jupyterhub:

    jupyter kernelspec list
    cd /usr/local/share/ && mkdir -p jupyter/kernels/
    cp -r /home/your-user-name/.local/share/jupyter/kernels/julia-0.4-your-julia-version /usr/local/share/jupyter/kernels/
    

这篇关于在 Julia 上只安装一个包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆