我正在使用多個命令行參數執行python腳本,但使用shell腳本。將shell腳本命令轉換爲命令行
命令我執行的shell腳本的執行是:
./scripts/run_qa.sh data/questions/questions.txt data/lexicons/paralex data/weights/paralex.txt data/database > output.txt
run_qa.sh文件看起來像下面(請解釋它是如何工作):
#!/bin/bash
set -u
set -e
if [ $# != 4 ]; then
echo "Usage: run.sh questions lexicon weights db"
exit 1
fi
questions=$1
lexicon=$2
weights=$3
db=$4
PYTHONPATH=$PWD/python python -m lex.gearman_worker $lexicon $weights $db < $questions
我想下面執行Python命令在命令行:
python -m python/lex/gearman_worker.py data/lexicons/paralex data/weights/paralex.txt data/database > output.txt
whic小時之後獲得錯誤:
/usr/bin/python: Import by filename is not supported.
UPDATE1:
gearman_worker.py文件導入其他文件,如部份:
import lex.parse
import lex.semantics
from collections import namedtuple
from collections import defaultdict
進口行給出的錯誤是這樣的:
ImportError: No module named lex.lexicon
UPDATE2(在linux終端上執行):
export PYTHONPATH=$/mnt/paralex-evaluation-gearman/python
PYTHONPATH = ./python python -m python/lex/gearman_worker data/lexicons/paralex data/weights/paralex.txt data/database > output.txt
給出:
PYTHONPATH: command not found
然後
python -m python/lex/gearman_worker data/lexicons/paralex data/weights/paralex.txt data/database > output.txt
給出:
File "/mnt/paralex-evaluation-gearman/python/lex/gearman_worker.py", line 3, in <module>
import lex.lexicon
ImportError: No module named lex.lexicon
@mu無:不好意思,更新它 – nlper 2015-02-11 11:07:39