2013-01-03 5 views
1

내 windows7 PC에 파이썬 2.7을 설치했습니다. 이제 Beautiful Soup을 거쳤습니다. 이제 BeautifulSoup4를 설치하기위한 두 가지 명령을 발견했습니다. easy_install beautifulsoup4pip install beautifulsoup4입니다.하지만 내 혼란은 어느 디렉토리에 있습니다. 내 python 폴더는 C:\Python27입니다. 그 명령을 어디에서 실행할 수 있도록 도와 주실 수 있습니까?beautifulsoup4 설치와 혼동

오류

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> 

감사

+1

모든 명령은 어느 디렉토리에서나 실행할 수 있습니다. BS 패키지는'C : \ Python27 \ Lib \ site-packages'에 설치 될 것입니다. 자세한 내용은 다음을 참조하십시오. http://docs.python.org/2/install/index.html#how-installation-works – bernie

+0

@bernie 설명을 참조하십시오. 오류가 발생했습니다. 나를 안내 해줘! – CodeLover

+1

http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows –

답변

1

가 시스템 Packager로를 설치할 수없는 경우, 당신은 easy_install을하거나 핍으로 설치할 수 있도록 아름다운 수프 4, PyPi를 통해 게시됩니다. 패키지 이름은 beautifulsoup4, 당신은 easy_install을가 없거나 설치 PIP 경우 같은 패키지는 당신이 Beautiful Soup 4 소스 TAR 파일을 다운로드해서 setup.py으로 설치할 수 있습니다, 파이썬이 파이썬 3

$ easy_install beautifulsoup4 

$ pip install beautifulsoup4 

에서 작동 . [(그렇지 않으면 C 런타임, * 평가 경로 확장에 알려져 가정 : 설치 \ python25 \ 파이썬 setup.py)를 설치 폴더로 이동하여 명령 setup.py를 실행합니다.]

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! 

테스트 :

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) 
관련 문제