wget is not recognized as an internal or external command, operable program or batch file
Asked Answered
P

3

7

I'm running Jupyter Notebook 6.0.1 via Anaconda Navigator, and was working on a Jupyter Notebook using Python 3. Need help to download data using wget. Appreciate a step-by-step solution as I'm new to coding. Thanks.

The code I typed to install wget:

!pip install wget

It returns: Requirement already satisfied: wget in c:\users\louie\anaconda3\lib\site-packages (3.2)

The code to download data:

import wget
!wget -q -O 'newyork_data.json' https://cocl.us/new_york_dataset
print('Data downloaded!')

I get this error message:

'wget' is not recognized as an internal or external command, operable program or batch file.

snapshot of code

Poore answered 19/3, 2020 at 15:14 Comment(2)
Does this answer your question? wget is not recognized as a command even though it is installed – Surprisal
for windows, you can download wget.exe from eternallybored.org/misc/wget and after downloading move the file wget.exe to C:\Windows\System32 or add it to path in environment variables – Keystroke
U
9
!pip install wget

!python -m wget -o 'newyork_data.json' https://cocl.us/new_york_dataset

or:

!pip install wget
import wget
url = 'https://cocl.us/new_york_dataset'
filename = wget.download(url)
print(filename)
Uralite answered 31/10, 2021 at 15:11 Comment(2)
While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: stackoverflow.com/help/how-to-answer . Good luck πŸ™‚ – Stamm
These days running pip install inside a notebook should be done without an exclamation point using the magic %pip install command to insure installations occur in the environment that the kernel that backs the active notebook runs. See more about the modern magic install commands here. – Guaco
L
2

I faced similar issue then. I did not get the solution but got a workaround, which is using curl in jupyter notebook. In an answer to this post: wget is not recognized as a command even though it is installed

For example

!curl -O https://cocl.us/sanfran_geojson
Linette answered 21/8, 2020 at 20:16 Comment(1)
I was thinking about this when I run into the same issue but I thought curl would have a more different format ;) – Nethermost
A
0
import urllib.request
url = 'https://cocl.us/new_york_dataset.json'
filename = 'newyork.json'
urllib.request.urlretrieve(url, filename)
print('GeoJSON file downloaded!')
ny_geo = r'newyork.json' # geojson file

You may use this code as well

Assignee answered 14/3, 2023 at 19:22 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.