You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Jupyter Notebook中使用wget命令?VS Code环境运行遇阻

在VS Code的Jupyter Notebook中使用wget的解决方法

Colab能直接用wget是因为它的运行环境是Linux虚拟机,默认自带这个工具,但本地VS Code的Jupyter用的是你电脑本身的系统环境,Windows默认没有wget,Linux/macOS如果没装也会报错,给你几个解决办法:

方法一:用Python内置库替代(跨平台通用)

不用依赖系统的wget,直接写Python代码下载,兼容性拉满:

import requests

# 替换成你要下载的文件链接
target_url = "https://example.com/your-file.zip"
# 替换成你想保存的文件名
save_name = "downloaded-file.zip"

response = requests.get(target_url)
with open(save_name, "wb") as file:
    file.write(response.content)

方法二:给系统安装wget

Windows环境

  • 用Chocolatey包管理器安装:打开管理员PowerShell,执行choco install wget(没装Chocolatey的话先装它)
  • 或者直接下载wget.exe,放到C:\Windows\System32这类系统PATH目录里,之后在Jupyter单元格里就能用!wget 你的链接了

Linux/macOS环境

  • Ubuntu/Debian:打开终端执行sudo apt install wget
  • macOS:用Homebrew执行brew install wget
    安装完成后,在Jupyter单元格里输入!wget 你的链接就能正常运行

内容的提问来源于stack exchange,提问作者Candy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 21:55:26