gdown 命令在 anaconda.cloud 的 jupyter 笔记本中不起作用

问题描述 投票:0回答:1

我在 anaconda.cloud 上使用带有内核的 Jupyter 笔记本

anaconda-2024.02-py310.

当我在单元格中执行以下操作时:

!pip install gdown
!gdown 1on54WRa6RCAQwrlpE2mABChNs4mNO2fd

它抛出以下错误:

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

怎么会抛出

command not found
错误?不是刚安装好,日志也证实了这一点吗?

有人可以帮助我吗?我从

Kernel
菜单重新启动了内核,但是它没有显示任何确认之类的东西。

我确实在我的 Mac 上安装了

gdown
,并且此命令适用于我的本地主机:

gdown 1on54WRa6RCAQwrlpE2mABChNs4mNO2fd

(当然,我在这里修改了 id)。

python jupyter-notebook anaconda gdown
1个回答
0
投票

这是gdown脚本路径的问题。在没有其他指令的情况下在单元上安装 gdwon

!pip install gdown

将会出现有关 gdwon 脚本不存在于您的环境路径中的警告

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

在另一个单元格中将 gdown scritp 的路径添加到 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'])

然后运行

!gdown <google_file_id>

它会毫无问题地下载

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]
© www.soinside.com 2019 - 2024. All rights reserved.