英文:
Can't use load function in julia simple script
问题
I'm trying to load an image in Julia but it gives me the error:
> ERROR: UndefVarError: load
not defined
Stacktrace:
> 1 top-level scope
> @ c:\folde1\folder2\project.jl
My code is:
using TestImages, Images, Statistics, Plots
a = load("rachado1.jpeg")
I'm running the code using vscode with Julia v1.9.
I already tried installing many packages (FileIO, ImageIO, ImageMagick), but the error persists.
I also tried in colab following these instructions (Julia in colab) and adding a new cell using the script above. But I got the same error.
英文:
I'm trying to load a image in Julia but it gives me the error:
> ERROR: UndefVarError: load
not defined
Stacktrace:
> 1 top-level scope
> @ c:\folde1\folder2\project.jl
My code is:
using TestImages, Images, Statistics, Plots
a = load("rachado1.jpeg")
I'm running the code using vscode with Julia v1.9
I already tried installing many packages (FileIO, ImageIO, ImageMagick), but the error persists.
I also tried in colab following these instructions (Julia in colab) and adding a new cell using the script above. But I got the same error.
答案1
得分: 2
正如丹·盖茨所说,问题不是导入FileIO:
# 尝试加载图像
img = load("test.jpg") # 错误:UndefVarError: load未定义
using FileIO # 现在首先导入FileIO
img = load("test.jpg") # 现在成功加载
希望对你有帮助!
英文:
as Dan Getz said, the issue is not importing FileIO:
# Try to load the image
img = load("test.jpg") # ERROR: UndefVarError: load not defined
using FileIO # now instead import FileIO first
img = load("test.jpg") # it now loads successfully
hope this helps!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论