pythonjupyter-notebookanacondagdown

gdown command not working in jupyter notebook in anaconda.cloud


I am using Jupyter notebook on anaconda.cloud with kernel anaconda-2024.02-py310.

When I execute the following in a cell:

!pip install gdown
!gdown 1on54WRa6RCAQwrlpE2mABChNs4mNO2fd

It throws the following error:

Defaulting to user installation because normal site-packages is not writeable
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: gdown in ./.local/lib/python3.10/site-packages (5.2.0)
...
/bin/bash: gdown: command not found

How come the command not found error is being thrown? Wasn't it just installed and the log also confirms that?

Could someone help me here? I restarted the kernel from the Kernel menu, however it doesn't show any confirmation sort of thing.

I did install gdown on my Mac and this command works on my local host:

gdown 1on54WRa6RCAQwrlpE2mABChNs4mNO2fd

(Of course, I have modified the id a bit here on SO).


Solution

  • It's a problem with gdown script's path. Install gdwon on a cell with no other instruction

    !pip install gdown
    

    There will be a warning about the gdwon script not present in your environment PATH

    Installing collected packages: gdown
      WARNING: The script gdown is installed in '/home/<user_id>/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    Successfully installed gdown-5.2.0
    

    In another cell add gdown scritp's path to PATH

    import os
    
    # Specify the directory you want to add to PATH
    new_directory = '/home/<user_id>/.local/bin'
    
    # Get the current PATH
    current_path = os.environ['PATH']
    
    # Add the new directory to the PATH
    os.environ['PATH'] = current_path + ':' + new_directory
    
    # Verify the change
    print(os.environ['PATH'])
    

    And then run

    !gdown <google_file_id>
    

    and it will download wihtout a problem

    Downloading...
    From: https://drive.google.com/uc?id=<google_file_id>
    To: /home/<user_id>/<some_file>
    100%|█████████████████████████████████████████| 426k/426k [00:00<00:00, 539MB/s]