subprocess.run(["huggingface-cli", "login", "--token", TOKEN]) 适用于 mac 但不适用于 Ubuntu

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

我正在尝试在 Jupyter 笔记本中运行

subprocess.run(["huggingface-cli", "login", "--token", TOKEN])
,它可以在 Mac 上运行,但在 Ubuntu 上出现以下错误。我检查了
pip install huggingface_hub
已被执行。

subprocess.run(["git", "lfs", "install"])
有效。

!huggingface-cli login
在 jupyter 单元格中得到错误
/bin/bash: huggingface-cli: command not found

有人可以帮忙吗?

python ubuntu subprocess
1个回答
0
投票

你的

huggingface_hub
不在你的
Ubuntu
系统的路径env变量中,它在你的
jupyter
和你的
terminal
会话之间是不一样的

在这里你可以做什么,获取可执行文件的

path
pip show huggingface_hub | grep Location
然后更新你的jupyter笔记本中的路径,例如:

import os
import sys
import subprocess

huggingface_bin_path = "/home/user/.local/bin"
os.environ["PATH"] = f"{huggingface_bin_path}:{os.environ['PATH']}"

subprocess.run(["huggingface-cli", "login", "--token", TOKEN])

用正确的替换

/home/user/.local/bin
TOKEN
,然后它应该工作

© www.soinside.com 2019 - 2024. All rights reserved.