2014-09-19 127 views
0

我想每天调用一次API并使用Python将数据保存在json中并将其转换为csv文件。尝试创建使用wget运行Python脚本的Shell脚本

我正在使用wget库来下载文件。 即使我正确安装了wget和我能够用它在Python Shell中,我不能运行在bash脚本,因为我得到的错误:

File "<stdin>", line 1, in <module> 
ImportError: No module named wget 

我怎么能在bash的安装wget的? 也许有一个内置的库,我可以用它来代替?

我的代码使用wget是:

import wget 

file_url = 'http://api-website' 
file_name = wget.download(file_url) 
+1

您可能需要使用PIP安装wget的Python模块。 – Dan 2014-09-19 23:41:36

+0

它的工作!谢谢! – Michal 2014-09-19 23:46:50

回答

1

下载wget形式this链接,并用以下命令安装:

提取Wget的

$ cd /tmp/wget 
$ gzip -dc < wget-2.2.tar.gz | tar -xf - 
$ cd wget-2.2 

构建Wget的

$ ./configure --prefix=/usr 
$ make 

安装Wget的(必须是root用户)

$ sudo make install 
+0

我正在使用cygwin,所以我不认为这些命令都适用。 – Michal 2014-09-19 23:43:41

+0

我编辑答案。 – Kasramvd 2014-09-19 23:47:13