简体   繁体   English

在bash脚本中运行Python脚本

[英]Running Python script inside bash script

I have a small problem when I try to run a script in bash. 我尝试在bash中运行脚本时遇到一个小问题。 First of all , my script work well when I run in terminal, but when I try to run by launcher in Ubuntu, I have this error 首先,当我在终端中运行时,我的脚本运行良好,但是当我尝试通过Ubuntu中的启动器运行时,出现此错误

" python: can't open file 'teste.py': [Errno 2] No such file or directory " python: can't open file 'teste.py': [Errno 2] No such file or directory

My script is similar at : 我的脚本类似于:

 #! /bin/bash
 # This script use sample.py
 python sample.py games.txt
 sleep 15

Other informations : 其他信息:

Ubuntu 11.04
Python 2.7

Thanks in advance 提前致谢

From the error message it looks like you have to specify the full path to your script in the launcher. 从错误消息看来,您必须在启动器中指定脚本的完整路径。

Try adding the full paths to your command in your bash script, ie similar to: 尝试在bash脚本中为命令添加完整路径,即类似于:

   python /home/glc/sample.py /home/glc/games.txt

By the way, what is this file teste.py ? 顺便问一下,这个文件teste.py什么? In your post you refer to script sample.py - is this a different file? 在您的文章中,您引用脚本sample.py这是一个不同的文件吗? How does it connect? 它如何连接? Did you possibly specify the wrong file name in the launcher? 您是否在启动器中指定了错误的文件名?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM