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:\Python27\Scripts\pip.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.
This question is related to
python
python-2.7
beautifulsoup
pip
import os
os.system("pip install beautifulsoup4")
or
import subprocess
exe = subprocess.Popen("pip install beautifulsoup4")
exe_out = exe.communicate()
print(exe_out)
If you have more than one version of python installed, run the respective pip command.
For example for python3.6 run the following
pip3.6 install beautifulsoup4
To check the available command/version of pip and python on Mac run
ls /usr/local/bin
The easy method that will work even in corrupted setup environment is :
To download ez_setup.py and run it using command line
python ez_setup.py
output
Extracting in c:\uu\uu\appdata\local\temp\tmpjxvil3
Now working in c:\u\u\appdata\local\temp\tmpjxvil3\setuptools-5.6
Installing Setuptools
run
pip install beautifulsoup4
output
Downloading/unpacking beautifulsoup4
Running setup.py ... egg_info for package
Installing collected packages: beautifulsoup4
Running setup.py install for beautifulsoup4
Successfully installed beautifulsoup4
Cleaning up...
Bam ! |DoneĀ¬
Source: Stackoverflow.com