Wget on a jupyter notebook (mac)

I am having difficulty using wget on jupyter notebook. I have installed this package using the following code: %conda install wget
I receive an error when I import the wget package, even after I have restarted the kernel after installation.

Please help.

Could you share the code for what you believe corresponds to this step with us?

This is after installation of wget:

%conda install wget

Collecting package metadata (current_repodata.json): done
Solving environment: done

#All requested packages already installed.

Note: you may need to restart the kernel to use updated packages.

This is the error I receive when I import wget

import wget

ModuleNotFoundError Traceback (most recent call last)
in
1 #mport os
2 #import urllib.request
----> 3 import wget

ModuleNotFoundError: No module named ‘wget’

That isn’t how wget works normally. Where did you find code telling you to type that? (Maybe from the poorly maintained project I reference later?)

Per the Anaconda page for wget,the documentation for wget is at https://www.gnu.org/software/wget/ where it says

It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without X-Windows support, etc

It isn’t a Python package. (Or at least not the one you installed so far.) One way to learn which are Python and aren’t is if you could install it via pip and it is at pypi, the Python Package Index, like numpy or pandas then it is a Python package and you may be able to use import. If you search wget at PyPi there you do get a wget listed, but this isn’t what you installed via conda. And you’ll note it isn’t well maintained as it hasn’t been updated since 2015 if you look at releases. You’ll note the one that got installed via conda is two years old and so much more recent than that one at PyPi.

Type the following in a Jupyter cell to get the help manual for this command line utility.

!wget --help

It is easy to use in your Jupyer notebook. Just put an exclamation in front of any wget command example you see. The exclamation point at the front of a typical command line command lets you run something you’d normally run in terminal in a Jupyter cell.

You can find examples of using wget here. The frist example under How to Download a File with wget you’d run in a jupyter cell with the following:

!wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.2.tar.xz

Note the exclamation point addition.


I don’t recommand this but I just verified it will work…
If you insist on using the poorly maintained wget you could import via import wget, the first run the following within your notebook:

%pip install wget

Most people when referencing wget will mean the current version of the command line utility you installed via %conda install wget.

Hi
Again thank you so much for your time and efforts. I am learning a lot from you and I am grateful of it. I am coming into another error when I type,
!wget --help
The error I have is the following below:
zsh:1: command not found: wget

Hmmm… new mac shell isn’t bash by default.
First try changing the cell to the following based on here:

%%bash
wget --help

I figured that was the issue that I was running into. I switched bash to zsh so I could run python 3 as my default.

1 Like

That’s a solution, too. I was starting with the less global option first.

1 Like