Scrapy" ImportError"在bash脚本中运行时

时间:2016-12-30 21:21:58

标签: python bash shell scrapy python-import

我有一个Python脚本(blah.py),第一行是:

import scrapy

当我写" python blah.py"它工作正常。

我有一个.sh脚本:

#!/bin/bash
python blah.py

当我用" sh blah.sh"执行.sh脚本时我收到错误:

ImportError: No module named scrapy

我无法弄清楚原因。我想在.sh文件中执行它,因为我在Python脚本之后执行其他一些命令。

1 个答案:

答案 0 :(得分:1)

看起来你可以在不同的环境中运行。

subprojects { project.configurations.getByName("compile").dependencies.each { if (it.name == foo){ // could be expanded to if it.name in collection //inherit testCompile project.configurations.dependencies.testCompile += it.sourceSets.test.output } } } 运行python blah.py时使用which python运行哪个python版本,并在python blah.py类型which python行之前运行bash脚本,检查终端。

确保两条路径相同才能使用