【问题标题】:"scrapy: command not found" on running through shell script通过 shell 脚本运行时出现“scrapy:找不到命令”
【发布时间】:2014-03-14 06:00:56
【问题描述】:

我有一个 shell 脚本,我通过它运行多个测试脚本,使用 Scrapy 抓取数据并导航到多个目录。脚本看起来像这样:

export PATH=$PATH
echo $PATH
cd wait/test/ScrapyCrawl
python runner.py #Test file
scrapy crawl Flipkart
scrapy crawl shopin1
scrapy crawl Happily
scrapy crawl Healthkart
scrapy crawl Dezains
scrapy crawl Fnp
scrapy crawl Vmate
scrapy crawl Exlives
scrapy crawl Dgifts
scrapy crawl Babyoye
scrapy crawl Purp
scrapy crawl Fabf
scrapy crawl Zansaar
scrapy crawl Shop19
scrapy crawl Engrave
scrapy crawl Carat
scrapy crawl Todu
scrapy crawl Hit
scrapy crawl Limeroad
scrapy crawl Perfico
python runner2.py #Test file
cd ..
cd ..
cd ..
cd subscribe/test/ScrapyCrawl
python runner.py #Test file
scrapy crawl Flipkart
scrapy crawl shopin1
scrapy crawl Happily
scrapy crawl Healthkart
scrapy crawl Dezains
scrapy crawl Fnp
scrapy crawl Vmate
scrapy crawl Exlives
scrapy crawl Dgifts
scrapy crawl Babyoye
scrapy crawl Purp
scrapy crawl Fabf
scrapy crawl Zansaar
scrapy crawl Shop19
scrapy crawl Engrave
scrapy crawl Carat
scrapy crawl Todu
scrapy crawl Hit
scrapy crawl Limeroad
scrapy crawl Perfico
python runner2.py #Test file.

但是当我运行脚本时,python 脚本可以正常运行但它会抛出错误

script2.sh: line 7: scrapy: command not found
script2.sh: line 8: scrapy: command not found
script2.sh: line 9: scrapy: command not found
script2.sh: line 10: scrapy: command not found
script2.sh: line 11: scrapy: command not found

等等 .. 无论何时调用scrapy。请帮忙。我已经用过export PATH=$PATH。我是 shell 脚本的新手。谢谢。

【问题讨论】:

  • 也许添加 PATH=$PATH:. 或将 scrapy .... 更改为 ./scrapy .... 可能会有所帮助
  • @anishsane 我已经用过export PATH=$PATH。添加PATH=$PATH 会有所不同吗?
  • 不是PATH=$PATH,添加PATH=$PATH:. ...但是,将scrapy更改为./scrapy是更好的选择。例如./scrapy crawl Flipkart

标签: python linux bash shell web-scraping


【解决方案1】:

这解决了问题...我没有使用export PATH=$PATHm,而是包含了scrapy的路径,现在使用export PATH=$PATH:/usr/local/bin

【讨论】:

    最近更新 更多