나는 이상한 파이썬 모듈 가져 오기 문제를 발견했습니다. 나는이 예외를 가지고 파이썬 모듈 가져 오기 차이 "string.maketrans"
from boilerpipe.extract import Extractor
나는
boilerpipe 모듈을 가져 오려는
는 :
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/boilerpipe-1.2.0-py2.7.egg/boilerpipe/extract/ __init__.py", line 2, in <module>
import urllib2
File "/usr/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 1140, in <module>
import ssl
File "/usr/lib/python2.7/ssl.py", line 58, in <module>
import textwrap
File "/usr/lib/python2.7/textwrap.py", line 40, in <module>
class TextWrapper:
File "/usr/lib/python2.7/textwrap.py", line 82, in TextWrapper
whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans'
나는 인터넷을 통해 검색 및 파이썬 2.6에서 'STR'모듈이 말하는 것 'string'모듈로 이름이 바뀌 었습니다. 그래서 이것은 코드 라이브러리에서 "문자열"모듈을 제대로 가져 오지 않은 것처럼 보입니다. 내가 home
디렉토리에서 파이썬 코드를 실행하고 (중 python
쉘을 사용하거나 python pyfile.py
를 사용하여) 동일한 코드 조각을 실행할 때
그러나 정말 이상한 일이다,는, 그것을 잘 작동합니다! 더 이상 가져 오기 오류가 없습니다.
그래서 약간 혼란 스럽습니다. 아무도 내게 어떤 힌트를 줄 수 있습니까?
감사합니다.
그래서 '집'디렉토리에서 다른 디렉토리에서 실행하는 것과 다른 점이 무엇입니까? – JXITC
홈 디렉토리에 string.py가 없습니다. –
예 ... 그게 내 문제를 해결했습니다. 나는 어리석은 실수를 저질렀다. 건배! – JXITC