Big Russ Big Russ - 9 months ago 87
Python Question

install beautiful soup using pip

I am trying to install BeautifulSoup using

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:
, then I tried adding it to the path, and running the
pip install package

tried it two different ways:

import sys
pip install beautifulsoup4

import sys
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.

Answer Source

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:\Python27\Scripts\pip install beautifulsoup4

or even

C:\Python27\Scripts\pip.exe install beautifulsoup4

Windows will then execute the pip program and that will use Python to install the package.