Can anyone help? when I tried to download a picture file from the web, I failed to do so and got the following messages:

I am following the class of " Working with images in Julia | Week 1 | 18.S191 MIT Fall 2020 | Grant Sanderson" and tried to write the code in my Julia notebook as:url = “https://i.imgur.com/VGPeJ6s.jpg” , and "download(url, “philip.jpg”) I got the error messages as follows;

failed process: Process('C:\WINDOWS\System32\curl.exe' -s -S -g -L -f -o philip1.jpg https://i.imgur.com/VGPeJ6s.jpg, ProcessExited(35)) [35]

  1. pipeline_error @ process.jl:525 [inlined]
  2. download_curl (::String, ::String, ::String)@ download.jl:44
  3. download @ download.jl:62 [inlined]
  4. top-level scope @ Local: 1 [inlined]

I get the same if I am not able to write into the current working directory.
Doing a

julia> cd(raw"c:\Temp")

julia> download(url, "philip.jpg")
"philip.jpg"

resolved it and results in a philip.jpg in c:\Temp.
It’s is probably the same within your notebook.
Check what

pwd()

gives and try to change into some directory you have write access. This directory must be on the notebook host system, if it isn’t a local running notebook.

As ?download says,

Note that this function relies on the availability of external tools such as curl, wget or fetch to download the file and is provided for convenience.

So, why not just use them directly (using ; to go into shell mode)?

shell> curl -o google.html https://www.google.com/
...
shell> wget -O google.html https://www.google.com/
...

You can use https://github.com/Arkoniak/UrlDownload.jl which download files without creating intermediate files.

1 Like

Thanks a lot! I tried and failed again. I got the following messages:

shell> curl -o google.html https://www.google.com/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- 0:00:20 --:–:-- 0curl: (7) Failed to connect to www.google.com port 443: Timed out

julia> wget -O google.html https://www.google.com/
ERROR: syntax: extra token “google” after end of expression
Stacktrace:
[1] top-level scope at C:\Users\Ginger Jiang.julia\packages\Pluto\dcxnF\src\evaluation\WorkspaceManager.jl:0

Hi, Thank you for replying to my help. I tried your way with Julia and notebook but failed again. It seems that I can’t creat file of “philip.jpg into my created c:\Temp.
julia> pwd()
“c:\Temp”
julia> cd(raw"c:\Temp”)
julia> download(url, “philip.jpg”)
ERROR: UndefVarError: url not defined
Stacktrace:
[1] top-level scope at REPL[23]:1

julia>

Hello Skoffer,
Thank you for replying. I have downloaded your provided link, after that I don’t know how to proceed, I am totally new about it. Please guide me further. Many thanks.

Hi oheil,
I just find a way to download that dog picture into my C:\Temp location as you suggested I should create. Now bypass that direct method, so the problem half solved! I can continue to work with that file without so much frustration. Thank you very much for your kind help!

Usage is straightforward.

First you need to install package itself

using Pkg
Pkg.add("UrlDownload")
Pkg.add("ImageMagick")

After that, you can use it as

using UrlDownload

img = urldownload("https://i.imgur.com/VGPeJ6s.jpg")

It appears you are using windows and not linux. I don’t know (or care about) the syntax to use curl/wget under windows, but you can surely find it online.


Hi Skoffer,
Thanks very much for taking the time to help me. After installed UrlDownload, I followed your method and I got the system response as per attached two pictures. Any further suggestions?

It looks like you have some issues with your network connection, as it is written in error message “connection reset by peer”

1 Like