我想使用“DataFrames、CSV、StatsPlots”包,而无需在重新启动计算机后等待时间,我正在尝试使用 PackageCompiler,但自述文件或帮助很难理解。
using using PackageCompiler
syso, sys = compile_incremental(:DataFrames,:CSV,:StatsPlots)
嗯,我害怕破坏系统镜像,所以,一开始,我不使用“force=true”选项。它显示错误消息:
...
Resolving package versions...
ERROR: LoadError: Unsatisfiable requirements detected for package WinRPM [c17dfb99]:
WinRPM [c17dfb99] log:
├─possible versions are: [0.3.3, 0.4.0-0.4.3] or uninstalled
├─restricted by compatibility requirements with PackageCompiler [9b87118b] to versions: [0.3.3, 0.4.0-0.4.3]
│ └─PackageCompiler [9b87118b] log:
│ ├─possible versions are: [0.5.0-0.5.1, 0.6.0-0.6.5] or uninstalled
│ └─restricted to versions * by an explicit requirement, leaving only versions [0.5.0-0.5.1, 0.6.0-0.6.5]
├─restricted by compatibility requirements with Compat [34da2185] to versions: 0.4.3 or uninstalled, leaving only versions: 0.4.3
│ └─Compat [34da2185] log:
│ ├─possible versions are: [1.0.0-1.0.1, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0-1.5.1, 2.0.0, 2.1.0, 2.2.0, 3.0.0, 3.1.0, 3.2.0] or uninstalled
│ └─restricted to versions 3.2.0 by an explicit requirement, leaving only versions 3.2.0
└─restricted by compatibility requirements with HTTPClient [0862f596] to versions: uninstalled — no versions left
└─HTTPClient [0862f596] log:
├─possible versions are: 0.2.1 or uninstalled
└─restricted by compatibility requirements with Compat [34da2185] to versions: uninstalled
└─Compat [34da2185] log: see above
最佳答案
PackageCompilerX 似乎可以工作。首先,包的版本非常敏感,它需要正确的版本才能让一切正常工作。
下面是我的两个julia 1.3.1的测试环境
- debian:apt -t不稳定安装 julia libjulia-dev
- archlinux:pacman -S julia
检查Julia的版本(PackageCompilerX仅在1.3.1之后工作)
julia> versioninfo()
Julia Version 1.3.1
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Xeon(R) CPU @ 2.20GHz
添加 PackageCompilerX 和所有要绘制到存储库的包
pkg> add https://github.com/KristofferC/PackageCompilerX.jl
pkg> status
Status `~/.julia/environments/v1.3/Project.toml`
...
将系统的Project.toml复制到当前目录以自定义您的开发环境,使用编辑器(这里是vim
)删除一些无法编译或不需要的包。
shell> rm Project.toml
shell> cp ~/.julia/environments/v1.3/Project.toml .
shell> vim Project.toml
激活本地包环境
julia> using PackageCompilerX
pkg> activate .
pkg> status # double check all package which you want have installed
Status `~/prj/julia/Project.toml`
[336ed68f] CSV v0.5.22
[a93c6f00] DataFrames v0.20.0
...
在 julia 提示符下自动生成 sybmol 数组
s=split(read("Project.toml", String),"\n")
pkgs=Symbol[]
for i in s
if (length(i) > 0) && !(i[1] in ['[','#'])
push!(pkgs, Symbol(split(i," ")[1]))
end
end
显示包装
julia> pkgs
10-element Array{Symbol,1}:
:CSV
:DataFrames
...
编译并输出到“dev.so”
julia> create_sysimage(pkgs, sysimage_path="dev.so")
退出 Julia,然后重新启动 Julia
julia -J dev.so
对这两种启动方法和结果进行基准测试:
time julia -q -e 'using Plots,UnicodePlots; unicodeplots(); display(plot(sin))'
# result: 35.175s
time julia -J dev.so -q -e 'using Plots,UnicodePlots; unicodeplots(); display(plot(sin))'
# result: 15.2365s
关于julia - 如何使用julia的PackageCompiler搭建PlotStats的快速启动环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59806941/