Windows环境运行gdown提示未识别命令的问题求助
问题现象
运行gdown命令时出现以下错误:
gdown : The term 'gdown' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
gdown https://drive.google.com/uc?id=1hs9HM0XJ2LPFghcn7ZMOs5qu5HexPXw ...
- CategoryInfo : ObjectNotFound: (gdown:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
已确认gdown已成功安装:
Name: gdown
Version: 4.7.1
Summary: Google Drive direct download of big files.
Home-page: http://github.com/wkentaro/gdown
Author: Kentaro Wada
Author-email: www.kentaro.wada@gmail.com
License: MIT
Location: C:\Users\myname\AppData\Roaming\Python\Python312\site-packages
Requires: beautifulsoup4, filelock, requests, six, tqdm
Required-by:
已尝试操作:
- 切换使用PowerShell、CMD、ISE、Git Bash、VSCode终端
- 将
...../Python/Python12/Scripts添加到PATH环境变量
解决步骤
定位gdown可执行文件的正确路径
从gdown的安装位置可知,其可执行文件应在C:\Users\myname\AppData\Roaming\Python\Python312\Scripts目录下(替换为你的实际用户名),而非你当前添加的...../Python/Python12/Scripts。先检查该目录下是否存在gdown.exe或gdown.py文件。更新PATH环境变量
- 右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
- 在「用户变量」或「系统变量」中找到
Path变量,点击「编辑」 - 添加路径
C:\Users\myname\AppData\Roaming\Python\Python312\Scripts - 保存设置后完全重启所有终端窗口,新的环境变量才会生效
直接通过Python模块调用gdown
如果PATH配置仍有问题,可绕过环境变量,直接用Python执行:python -m gdown https://drive.google.com/uc?id=1hs9HM0XJ2LPFghcn7ZMOs5qu5HexPXw...若存在多个Python版本,可指定版本号:
py -3.12 -m gdown https://drive.google.com/uc?id=1hs9HM0XJ2LPFghcn7ZMOs5qu5HexPXw...强制重新安装gdown
若上述方法无效,执行强制重装命令,确保可执行文件正确生成:pip install --upgrade --force-reinstall gdown安装完成后,终端会输出gdown.exe的所在路径,确认该路径已加入PATH。
内容的提问来源于stack exchange,提问作者Yajax

