简体   繁体   English

如何从文件中运行python脚本? (UNIX)

[英]How do I run a python script from a file? (UNIX)

Basically what I want to do is make a file called doPython and in this file I want to do the command: 基本上我想做的是创建一个名为doPython的文件,在这个文件中我想要执行命令:

python myFile.py data.txt

I've tried Googling and making a few scripts but I can't seem to get it to work. 我已经尝试过谷歌搜索和制作一些脚本,但我似乎无法让它工作。 It says "No such file or directory when I try with 它说“我尝试时没有这样的文件或目录

#!/usr/bin/env python
python myFile.py data.txt

#!/usr/bin/env python says that your script is to be run with the Python interpreter. #!/usr/bin/env python说你的脚本是用Python解释器运行的。 You just need to call sh or bash : 你只需要打电话给shbash

#!/bin/sh
python myFile.py data.txt

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

相关问题 如何在 Unix 中运行 Python 脚本 - How do I run a Python script in Unix 如果我的脚本使用从其他文件导入的函数,如何让我的脚本从 Unix 上的可执行 python 文件运行? (ModuleNotFoundError) - How can I make my script run from executable python file on Unix if it uses functions imported from other files? (ModuleNotFoundError) 如何从 Photoshop 脚本运行 Python 脚本? - How do I run a Python script from a Photoshop script? 如何从主 python 文件正确运行单独的 python 脚本? - How do I properly run a separate python script from main python file? 如何从矩阵导入数据文件并从python脚本运行.m文件? - How do I import a data file as a matrix and run a .m file from a python script? 如何使用 python 2 安装在 Unix 上运行 python 3 脚本 - how to run python 3 script on Unix with python 2 installation 如何从批处理文件运行充当cmd实例的子进程的python脚本? - How do I run a python script, from a batch file, that acts as a subprocess of the cmd instance? 如何使用 Python 中的参数运行 PowerShell 脚本 - How do I run a PowerShell script with parameters from Python 如何运行从bash导入yaml的python 3脚本 - How do I run a python 3 script that imports yaml from bash 如何从 C# 运行 Python 脚本? - How do I run a Python script from C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM