在Julia上全局安装一个软件包 [英] Install just one package globally on Julia

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

问题描述

我在计算机上安装了新的Julia机器,该机器想用作实验室中各种人员的数字处理服务器.似乎有一个名为jupyterhub wich的好程序包,它使Jupyter Notebook接口同时可用于各种客户端.我找不到的网页开始提示类似首先在全局安装IJulia,然后安装JupyterHub ..."之类的内容

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..."

我似乎找不到在全球安装ONE软件包的好方法.

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

推荐答案

更新

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

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" 

旧帖子

首先在全局安装IJulia,然后安装JupyterHub ..."

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

我不知道这是否成立,通过执行以下步骤,可以在安装Jupyterhub之后安装IJulia.

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

此问题已由Stefan 此处回答.卡平斯基.因此,我们需要的只是使用此方法来安装IJulia.jl软件包.

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.

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

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"

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

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....

让IJulia与Jupyterhub合作

为了使IJuliaJupyterhub对于所有用户都可以正常工作,应将文件夹your/user/.local/share/jupyter/kernels/julia/复制到/usr/local/share/jupyter/kernels/.我写下了测试中使用的一些步骤 Dockerfile .代码很丑陋,但是可以用.

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.

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

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. 创建我们的全局软件包目录并设置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/

  • 使用程序包管理器安装"IJulia":

  • install "IJulia" using package manager:

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

  • kernelspec s复制到/usr/local/share/jupyter/kernels/,可由Jupyterhub添加的任何新用户使用:

  • 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天全站免登陆