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

时间:2013-08-30 08:21:51

标签: python python-2.7

我想学习python,所以我尝试安装python 2.7,但是当我设置环境时,有一个错误告诉语法错误与第一个冒号相反。有人帮帮我吗?

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

1 个答案:

答案 0 :(得分:0)

命令#include <stdlib.h> #include <string.h> #include <stdio.h> #define MAXN 5000000 // This is an array of characters: char c[MAXN]; // This is an array of pointers pointing to individual characters. Essentially, this is an index. char *a[MAXN]; static int pstrcmp(const void *p1, const void *p2){ // wrapper between strcmp and qsort's compare signature. // See: man 3 qsort -- http://linux.die.net/man/3/qsort return strcmp(* (char * const *) p1, * (char * const *) p2); } int main() { int ch; size_t n = 0; while ((ch = getchar()) != EOF) { // In this loop, you systematically build up an index, where a[i] points to c[i]. a[n] = &c[n]; c[n] = ch; n++; } c[n] = 0; qsort(a, n, sizeof(char *), pstrcmp); // Now, you sort the _index_. printf("\nc: %s\n", c); // Print Original array. printf("a: "); // Print Ordered array: for (size_t i = 0; i < n; i++) printf("%c", *a[i]); // Look at the indirection printf("\n"); return 0; } 不是python命令,而是设置[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")变量的操作系统命令。

您在 Python解释器中遇到此错误,该错误由您在终端中输入的命令PATH触发(Windows PowerShell)

请注意该行左侧的python。它声明你在 Python解释器

里面

请输入>>>退出 python interpreter ,然后输入命令。它应该工作!