2014-03-19 5 views
3

python3 용 mechanize 라이브러리를 설치했습니다. https://github.com/adevore/mechanize/tree/python3python3의 mechanicalize 브랜치를 가져올 때 오류가 발생했습니다.

하지만 가져올 때이 오류가 발생합니다.

Python 3.3.3 (default, Dec 30 2013, 16:15:14) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> 
>>> import mechanize 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/__init__.py", line 122, in <module> 
    File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_mechanize.py", line 15, in <module> 
    File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_html.py", line 16, in <module> 
ImportError: cannot import name _sgmllib_copy 

하지만 mechanize가 동일한 virtualenv 디렉토리에 설치되어 있어야합니다.

$ pip freeze 
## FIXME: could not find svn URL in dependency_links for this package: 
mechanize==0.2.6.dev-20140305 
pyquery==1.2.8 
Warning: cannot find svn location for mechanize==0.2.6.dev-20140305 

터미널에서 작동하는 데 익숙하지 않아서이 문제를 해결하는 방법을 모르겠습니다.

누구든지이 문제를 해결할 수 있도록 도와 주시겠습니까?

미리 감사드립니다.

+0

파이썬 3에서 작업하려면 기계화 작업을 수행 한 적이 있습니까? –

답변

2

당신이 참조한 저장소에 import이 잘못 사용되었습니다. mechanize._html 모듈 importmechanize._sgmllib_copy을 얻으려고하지만 PEP 328에서 가져 오기를 수행 할 것으로 예상되는 _sgmllib_copy입니다. 오히려 상대 수입을 사용해야합니다. from . import _sgmllib_copy.

+0

도움 주셔서 대단히 감사합니다! 그래서, 내가해야 할 일은 "mechanize._html"파일을 수정하는 것입니까? 나는 그 html 파일을 보지 못했다. – crzyonez777

+0

'mechanize._html' 모듈을 뒷받침하는 파일을'mechanize/_html.py '라고합니다. –

1

https://github.com/adevore/mechanize/tree/python3

이 지점은 모든 _sgmllib_copy.py 포함되어 있지 않습니다. master 브랜치에서이 파일을 가져 왔습니다 (print smthprint (smth)으로 변경해야 함). 그러나 나는 아직도 어떻게 수입품이 이용되어야하는지 얻지 않는다. _html.py 모듈에서 (이 기계화 폴더에있는 것)를 사용

from . import _sgmllib_copy as sgmllib

이 잘못인가? 하지만 from . import _beautifulsoup이 작동하는 것 같습니다.

+0

도움 주셔서 감사합니다 !! 마스터 분기에서 _sqmllib_copy를 추가하고 다시 설치했습니다. 이제이 오류가 있습니다 "IndentationError : unexpected indent"... – crzyonez777

+0

그래서이 오류를 소스 파일에서 수정할 수 있습니다. 그것이 발생하는 라인 번호를 보여주고 있습니까? 아니면 내 수정 https://drive.google.com/file/d/0B2tqHfR7_fJua2pwNUFmSDlIWnM/edit?usp=sharing을 사용하려고 할 수 있습니다 그것은 나를 위해 작동하지 않습니다 아직 설치하지만 –

+0

아마 '아무튼 우리 프록시 서버 때문에 나를 위해 일하지 마라. –

관련 문제