问题描述
我正在尝试使用pip安装软件包.我尝试从Python Shell运行pip install
,但得到一个SyntaxError
.为什么会出现此错误?如何使用pip安装软件包?
I'm trying to use pip to install a package. I try to run pip install
from the Python shell, but I get a SyntaxError
. Why do I get this error? How do I use pip to install the package?
>>> pip install selenium
^
SyntaxError: invalid syntax
推荐答案
pip是从命令行而不是Python解释器运行的.这是一个安装模块的程序,因此您可以从Python使用它们.一旦安装了模块,就可以打开Python shell并执行import selenium
.
pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. Once you have installed the module, then you can open the Python shell and do import selenium
.
Python shell不是命令行,它是一个交互式解释器.您在其中键入Python代码,而不是命令.
The Python shell is not a command line, it is an interactive interpreter. You type Python code into it, not commands.
这篇关于为什么要"pip install"安装Python内引发SyntaxError吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!