为什么“pip install"?在 Python 内部引发 SyntaxError? [英] Why does "pip install" inside Python raise a SyntaxError?

查看:41
本文介绍了为什么“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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆