为什么要"pip install"安装Python内引发SyntaxError吗? [英] Why does "pip install" inside Python raise a SyntaxError?

查看:346
本文介绍了为什么要"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天全站免登陆