简体   繁体   English

安装时设置Python环境变量时出现语法错误

[英]Syntax Error when setting Python Environment variable on installation

I want to learn python so I tried to install python 2.7, but when I set the environment, there was an error telling the syntax error that reverse to the first colon. 我想学习python,所以我尝试安装python 2.7,但是在设置环境时,出现错误告诉语法错误,该错误与第一个冒号相反。 Anyone help me, please? 有人帮我吗?

>>> [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")
SyntaxError: invalid syntax

The command [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\\Python27", "User") is not an python command instead this an operating system command to the set the PATH variable. 命令[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\\Python27", "User")不是python命令,而是用于设置PATH变量的操作系统命令。

You are getting this error as you are inside the Python interpreter which was triggered by the command python you have entered in the terminal (Windows PowerShell) . 您在Python解释器中时会遇到此错误,该解释器是由您在终端机(Windows PowerShell)中输入的命令python触发的。

Please note the >>> at the left side of the line. 请注意行左侧的>>> It states that you are on inside Python interpreter 它表明您正在使用Python解释器

Please enter quit() to exit the python interpreter and then type the command. 请输入quit()退出python解释器 ,然后键入命令。 It should work! 它应该工作!

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

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