简体   繁体   English

无法使用./从命令行运行python脚本<scriptname>

[英]Unable to run python script from command line using ./<scriptname>

Tried searching many posts but unable to find the answer. 尝试搜索许多帖子,但找不到答案。

I have a simple python script (test.py) written as: 我有一个简单的python脚本(test.py)编写为:

!/usr/bin/env python (tried with #!/usr/bin/python) !/ usr / bin / env python(已尝试#!/ usr / bin / python)

print("Hellow World") 打印(“ Hellow World”)

but when I am trying to run this script from command line (from the script location) as ./test.py, it is always giving error "'.' 但是,当我尝试从命令行(从脚本位置)以./test.py身份运行此脚本时,它始终会给出错误“'”。 is not recognized as an internal or external command, operable program or batch file." 不被识别为内部或外部命令,可操作程序或批处理文件。”

"which python" is giving me below path: “哪个python”给我以下路径:

!/cygdrive/c/Users/User>/AppData/Local/Programs/Python/Python36-32/python !/ cygdrive / c / Users / User> / AppData / Local / Programs / Python / Python36-32 / python

I am able to run the script using "python test.py" but unable to understand the issue with "./" 我可以使用“ python test.py”运行脚本,但无法理解“ ./”的问题

You are running on Windows and trying to use semantics from a POSIX-like shell. 您正在Windows上运行,并尝试使用类似POSIX的外壳中的语义。

Instead of running ./tesy.py try start test.py 代替运行./tesy.py尝试start test.py

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

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