我对Python很陌生。我已经在Windows上安装了Python 3.7.3
,并且想使用CMD运行.py
文件。
命令就像py xxx.py
,实际上是用于从服务器下载某些文件的命令。
当系统询问“是否可以下载”时,我点击了。
然后出现一条消息。
该脚本在系统上需要curl或wget,请安装它们 首先在运行脚本之前!
程序将退出。
但是当我尝试运行pip install wget
时,会出现以下消息:
已满足要求:wget加入 c:\ users \ qin_l \ appdata \ local \ programs \ python \ python37-32 \ lib \ site-packages (3.2)
当我输入py -m wget xxx.file
时,我可以下载文件(不是我想要的文件)
我想不能穿过窗户的部分是
# Check if curl or wget commands exsit on your computer
if sys.version_info >= (3,0):
status_curl, result = subprocess.getstatusoutput('which curl')
status_wget, result = subprocess.getstatusoutput('which wget')
else:
status_curl, result = commands.getstatusoutput("which curl")
status_wget, result = commands.getstatusoutput("which wget")
相应地
if status_curl == 0:
cmd='curl -g "'+cmd+'" -o '+ ncout
elif status_wget == 0:
cmd='wget "'+cmd+'" -O '+ ncout
else:
sys.exit('\nThe script will need curl or wget on the system, please install them first before running the script !\nProgram will exit now !\n')
似乎wget
可以在Python中工作,但不能在py文件中工作。我在这里很困惑。我必须安装Linux并在Ubuntu中运行命令吗?
答案 0 :(得分:0)
您拥有的脚本期望将wget
或curl
作为命令行工具安装,即。您可以从CMD提示符下运行它们。
令人困惑的是,还有python package called wget,它与pip install wget
一起安装,但是完全不同。.
要安装命令行wget
,请先使用Powershell安装Scoop,然后再将安装wget
与scoop install wget
一起安装。
答案 1 :(得分:0)
我试图将“哪个卷曲”更改为“哪里卷曲”,并且不再显示错误消息。但是由于“由于遇到错误而禁用SSL”,因此无法下载文件。
转为我必须在计算机上安装Ubuntu,它终于可以工作了。