0

I try to install BeautifulSoup library for HTML parsing. I try to use the pip command. I have completed the preliminaries. I add C:\Python27; in the PATH. I ran it typing python and import pip. It's all ok.I type

>>>pip install beautifulsoup4
      File "<stdin>", line 1
        pip install beautifulsoup4
                  ^
>>>python -m pip install beautifulsoup4
      File "<stdin>", line 1
        python -m pip install beautifulsoup4
                    ^

What step do I miss? I cannot figure out. The site of the library.

Jacob Fuchs
  • 359
  • 1
  • 3
  • 14

3 Answers3

1

pip should be executed from your OS shell, not from a Python shell. E.g.

C:\>python -m pip install beautifulsoup4

or

you@machine$ python -m pip install beautifulsoup4

You may also be able to just run pip directly instead of python -m pip.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • @abccd, sorry, I don't understand your comment. – ChrisGPT was on strike Apr 08 '17 at 18:29
  • 1
    Your first example should be `C:\>py -3 -m pip install beautifulsoup4` since `python` isn't a default command in Windows. – Taku Apr 08 '17 at 18:31
  • @abccd, are you saying that there's a `py` binary installed by default on Windows? I don't think so, but I haven't used Windows in quite some time. In any case, the question specifies that the OP added the Python directory to `%PATH%` and was able to run Python with `python`. – ChrisGPT was on strike Apr 08 '17 at 18:34
  • Well, it's all good since that dir is added to %PATH%. If it's not, `py` is the valid command while `python` does not exist – Taku Apr 08 '17 at 18:39
1

pip is it's own command, not run from the python interpreter.

A Hettinger
  • 448
  • 2
  • 11
0

Ela re Θανάση it's easy :
cd C:\Python27\Scripts
pip install beautifulsoup4

t.m.adam
  • 15,106
  • 3
  • 32
  • 52