Why does quot;pip installquot; inside Python raise a SyntaxError?(为什么“pip install?在 Python 内部引发 SyntaxError?)
问题描述
我正在尝试使用 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么“pip install"?在 Python 内部引发 SyntaxError?


基础教程推荐
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01