gpt4 book ai didi

Julia spawn 'source' 导致没有这样的文件或目录

转载 作者:行者123 更新时间:2023-12-02 21:05:04 26 4
gpt4 key购买 nike

Julia 的run 函数似乎难以运行source。奇怪的是,如果我在 shell 中运行完全相同的命令,它不会有问题。

有没有办法从 Julia 以编程方式运行命令?

julia> cmd = "/home/me/tensorflow/bin/activate"
"/home/me/tensorflow/bin/activate"

julia> run(`ls $cmd`)
/home/me/tensorflow/bin/activate

julia> run(`source $cmd`)
ERROR: could not spawn `source /home/me/tensorflow/bin/activate`: no such file or directory (ENOENT)
in _jl_spawn at process.jl:262
in anonymous at process.jl:415
in setup_stdio at ./process.jl:403
in __spawn#58__ at ./process.jl:414
in run at ./process.jl:530

shell> source /home/me/tensorflow/bin/activate

最佳答案

源是内置命令

像这样尝试:

run(`zsh -c "source $cmd"`)

run(`bash -c source $cmd`)

window :

run(`cmd /c 'echo xxx'`)

关于Julia spawn 'source' 导致没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36484596/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com