python - 在Powershell中执行python脚本时获取 "ParserError: (:) [], ParentContainsErrorRecordException"

标签 python powershell

我尝试在 Powershell 中执行 python 脚本,出现此错误。
脚本本身是正确的,我可以在 CMD 中执行相同的命令。

那么我应该在powershell中写什么?

"C:\Program Files\Python36\python.exe" .\setup.py install
At line:1 char:40
+ "C:\Program Files\Python36\python.exe" .\setup.py install
+                                        ~~~~~~~~~~
Unexpected token '.\setup.py' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

最佳答案

你需要在你的应用程序名称前面放一个&符号(这里是python.exe)

& "C:\Program Files\Python36\python.exe" .\setup.py install

PowerShell 需要 & 符号将字符串解释为文件名。

关于python - 在Powershell中执行python脚本时获取 "ParserError: (:) [], ParentContainsErrorRecordException",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48438231/

相关文章:

sql - 在PowerShell中处理System.DBNull

.net - 处理 StreamWriter 而不在一行中声明变量

python - Anaconda 3 和 Python 3.7 的 Pyinstaller 无法工作?

python - 为什么即使子进程已完成,Popen.poll() 也会返回 None 的返回码?

python - 装饰器和类方法

shell - 让 vim 将当前文件路径传递给我的 shell

xml - 或者在 XPath 表达式中从多个节点名称中进行选择

python - Scipy - 非线性方程组的所有解

Python - time.sleep 的替代品

azure - 有没有办法以完整模式部署 "nested"或 "tiered"资源(即服务总线队列)或达到等效结果?