使用pypm加载包时总是出现相同的SyntaxError: invalid syntax
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> pypm install pyramid
File "<stadin>", line 1
pypm install pyramid
^
SyntaxError: invalid syntax
我下载了ActivePython-2.7.2.5-win32-x86,并按照说明书上的步骤安装了软件。但是pypm完全无法使用。从说明书上看,我以为在成功安装Python后,只需要在IDLE(Python的图形界面)中输入以下代码:
C:\> pypm install pandas
就可以安装和加载这个包。然而,我一直收到下面显示的语法错误:
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> C:\> pypm install pyramid
SyntaxError: invalid syntax
当我尝试在Python交互式命令行中运行相同的代码时,也出现了同样的错误信息:
C:\> pypm install pandas
在下面的Python交互式命令行中:
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> C:\> pypm install pyramid
File "<stadin>", line 1
C:\> pypm install pyramid
^
SyntaxError: invalid syntax
我还尝试打开Python包管理器(PyPM)查看是否有什么问题。在PyPM窗口中,我发现了以下几行:
'pypm' is not recognized as an internal or external command,
operable program or hatch file.
C:\windows\system32>
我真的不知道我哪里出错了,我尝试卸载ActivePython 2.7.2.5并重新安装了好几次,还是收到同样的错误信息。
当我在Python交互式命令行中输入:
pypm install pandas
时,依然出现同样的错误信息。
我尝试卸载ActivePython 2.7.2.5并重新安装了好几次,还是收到同样的错误信息。我使用的是Windows 7操作系统。
2 个回答
我遇到了同样的问题。不过,给出的答案并不完全准确。
在刚安装好的Windows系统上使用ActivePython 2.7.8.10时,我尝试做和提问者一样的事情,结果也收到了同样的错误信息。当时我也是在使用Python 2.7.8的命令行界面。
正确的做法是,在ActiveState Python 2.7的文件夹里,有一个Python包管理器(PyPM)的图标。点击这个图标会打开一个命令提示窗口,里面显示了以下内容:
PyPM 1.4.3(Python包管理器)简要帮助: 输入“pypm install PACKAGE”来安装一个包。 输入“pypm search KEYWORDS”来搜索包。 输入“pypm upgrade”来升级已安装的包。
输入“pypm help”来查看完整帮助。 C:\Windows\system32>
在这里,我可以输入命令来运行pypm并安装我想要的包。
需要注意的是,这个方法只适用于ActiveState Python包。其他版本的Python没有安装PyPM,所以如果你想使用其他版本的Python,就得先弄清楚怎么安装PyPM。
你不能在Python解释器的提示符下调用
pypm install pyramid
这个命令。
你需要在命令行控制台或者终端中输入这个命令。