0

I have installed python 2.7 in my windows7 PC.Now i went through the Beautiful Soup.Now I found two commands to install BeautifulSoup4. easy_install beautifulsoup4 and pip install beautifulsoup4.But my confusion is in which directory i have to run those commands.My python folder is C:\Python27 . Can you help me where to run that command?

Error

    Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Arup Rakshit>cd..

C:\Users>cd..

C:\>cd C:\Python27

C:\Python27>python.exe virtualenv.py selenv
New python executable in selenv\Scripts\python.exe
Installing setuptools....................................done.
Installing pip.........................done.

C:\Python27>cd selenv\Scripts\

C:\Python27\selenv\Scripts>pip.exe install selenium
Downloading/unpacking selenium
  Downloading selenium-2.28.0.tar.gz (2.1MB): 2.1MB downloaded
  Running setup.py egg_info for package selenium
    C:\Python27\Lib\distutils\dist.py:267: UserWarning: Unknown distribution opt
ion: 'src_root'
      warnings.warn(msg)

    warning: no files found matching 'docs\api\py\index.rst'
Installing collected packages: selenium
  Running setup.py install for selenium
    C:\Python27\Lib\distutils\dist.py:267: UserWarning: Unknown distribution opt
ion: 'src_root'
      warnings.warn(msg)

    warning: no files found matching 'docs\api\py\index.rst'
Successfully installed selenium
Cleaning up...

C:\Python27\selenv\Scripts>python.exe my_selenium_script.py
python.exe: can't open file 'my_selenium_script.py': [Errno 2] No such file or d
irectory

C:\Python27\selenv\Scripts>python.exe my_selenium_script.py
Hello

C:\Python27\selenv\Scripts>cd..

C:\Python27\selenv>pip install beautifulsoup4
'pip' is not recognized as an internal or external command,
operable program or batch file.

C:\Python27\selenv>

Thanks

CodeLover
  • 956
  • 5
  • 23
  • 39
  • 1
    You can run either of those commands from any directory. The BS package will be installed to `C:\Python27\Lib\site-packages`. For more details please refer to: http://docs.python.org/2/install/index.html#how-installation-works – mechanical_meat Jan 03 '13 at 19:15
  • @bernie please see the description, I am getting error. guide me here! – CodeLover Jan 03 '13 at 19:21
  • 1
    http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows – Paul Collingwood Jan 03 '13 at 19:23
  • @PaulC that link is too much confusing... lots of advices are there.. which to follow i am confused.I have installed python 2.7 and selenium also. Now how to get the `beautiful soup` instruct me in my condition!! Hope it would be better for me – CodeLover Jan 03 '13 at 19:31
  • http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip – Paul Collingwood Jan 03 '13 at 19:59
  • @bernie Atlast i have given an brrief workout,which worked for me and hope other also would get helpful. At last thanks for your time! – CodeLover Jan 03 '13 at 21:13

1 Answers1

0

Beautiful Soup 4 is published through PyPi, so if you can’t install it with the system packager, you can install it with easy_install or pip. The package name is beautifulsoup4, and the same package works on Python 2 and Python 3.

$ easy_install beautifulsoup4

$ pip install beautifulsoup4

If you don’t have easy_install or pip installed, you can download the Beautiful Soup 4source tarball and install it with setup.py. [Go to that folder and run command setup.py install (assuming *.py is known in path extensions, otherwise run c:\python25\python setup.py install).]

C:\Python27\beautifulsoup4-4.1.0>cd C:\Python27\beautifulsoup4-4.1.0
C:\Python27\beautifulsoup4-4.1.0>setup.py install 'here I am done!

Test :

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Arup Rakshit>cd..

C:\Users>cd..

C:\>cd C:\Python27

C:\Python27>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib import urlopen
>>> from bs4 import BeautifulSoup
>>> source = BeautifulSoup(urlopen("http://www.google.com/"))
>>> tables = source.findAll('td')
>>> import csv
>>> writer = csv.writer(open('filename.csv','w'))
>>> writer.writerow(rows)
CodeLover
  • 956
  • 5
  • 23
  • 39