使用 pip 安装漂亮的汤 [英] install beautiful soup using pip
问题描述
我正在尝试在 Python 2.7 中使用 pip
安装 BeautifulSoup.我不断收到错误消息,但不明白为什么.
我按照说明安装了pip,它安装到以下目录:c:Python27Scriptspip.exe
,然后我尝试将其添加到路径中,并运行pip install package
命令.
尝试了两种不同的方式:
导入系统sys.path.append('C:\Python27\Scripts\pip.exe')pip 安装 beautifulsoup4导入系统sys.path.append('C:\Python27\Scripts')pip 安装 beautifulsoup4
两者都给我这个错误信息:
<预><代码>>>>pip 安装 beautifulsoup4语法错误:无效语法shell 突出显示了安装"这个词,并说它是无效的语法.
我不知道发生了什么,因此非常感谢您的帮助.
pip
是一个命令行工具,而不是 Python 语法.
换句话说,在你的控制台中运行命令,不是在 Python 解释器中:
pip install beautifulsoup4
您可能必须使用完整路径:
C:Python27Scriptspip install beautifulsoup4
甚至
C:Python27Scriptspip.exe 安装 beautifulsoup4
Windows 将执行 pip
程序,那个将使用 Python 安装包.
另一种选择是使用 Python -m
命令行开关来运行 pip
模块,然后它的操作与 pip
完全一样命令:
python -m pip install beautifulsoup4
或
python.exe -m pip install beautifulsoup4
I am trying to install BeautifulSoup using pip
in Python 2.7. I keep getting an error message, and can't understand why.
I followed the instructions to install pip, which was installed to the following directory: c:Python27Scriptspip.exe
, then I tried adding it to the path, and running the pip install package
command.
tried it two different ways:
import sys
sys.path.append('C:\Python27\Scripts\pip.exe')
pip install beautifulsoup4
import sys
sys.path.append('C:\Python27\Scripts')
pip install beautifulsoup4
both give me this error message:
>>> pip install beautifulsoup4
SyntaxError: invalid syntax
the shell is highlighting the word "install" and saying that it's invalid syntax.
I have no idea what's going on, so any help would be greatly appreciated.
pip
is a command line tool, not Python syntax.
In other words, run the command in your console, not in the Python interpreter:
pip install beautifulsoup4
You may have to use the full path:
C:Python27Scriptspip install beautifulsoup4
or even
C:Python27Scriptspip.exe install beautifulsoup4
Windows will then execute the pip
program and that will use Python to install the package.
Another option is to use the Python -m
command-line switch to run the pip
module, which then operates exactly like the pip
command:
python -m pip install beautifulsoup4
or
python.exe -m pip install beautifulsoup4
这篇关于使用 pip 安装漂亮的汤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!