shell终端进行两步操作即可:
(1)export PYTHONPATH=项目路径(ps:如/data/project/test)
(2)env | grep PYTHONPATH若有 PYTHONPATH=/data/project/test则说明成功。
在shell脚本中加入python工程路径到PYTHONPATH变量中:如下
#!/bin/sh #chkconfig: 35 20 80 #description: start mount mydisk export PYTHONPATH=/mnt/udisk/project/myproject/wanwenyc /mnt/udisk/project/myenv/myfirstenv/bin/python /mnt/udisk/project/myproject/wanwenyc/WWSpider/mybase/spiderHanMan.py &
如上,在运行的shel脚本中将工程目录/mnt/udisk/project/myproject/wanwenyc加入到PYTHONPATH变量中