반응형
python3.3에서 docx를 가져올 때 ImportError : No module named 'exceptions'오류가 있습니다.
가져올 때 docx
다음 오류가 발생합니다.
>File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/docx-0.2.4-py3.3.egg/docx.py", line 30, in <module>
from exceptions import PendingDeprecationWarning
ImportError: No module named 'exceptions'
이 오류 ( python3.3
, docx 0.2.4
) 를 수정하는 방법은 무엇입니까?
파이썬 3x를 사용하는 경우 pip install docx
대신 하지 마십시오.
pip install python-docx
파이썬 3x와 호환됩니다.
공식 문서 : https://pypi.org/project/python-docx/
- 다음을 사용하여 docx 모듈 제거
pip uninstall docx
- http://www.lfd.uci.edu/~gohlke/pythonlibs/
python_docx-0.8.6-py2.py3-none-any.whl
에서 파일 다운로드 pip install python_docx-0.8.6-py2.py3-none-any.whl
docx를 다시 설치하려면 실행하십시오 . 이것은 위의 가져 오기 오류를 원활하게 해결했습니다. 솔루션을 제공하기 위해 ...
Python 3에서 예외 모듈이 제거되고 모든 표준 예외가 내장 모듈로 이동되었습니다. 따라서 표준 예외를 명시 적으로 가져올 필요가 더 이상 없습니다.
이전 의견에서 언급했듯이 문제는 docx 모듈이 Python 3과 호환되지 않는다는 것입니다. github의 pull-request에서 수정되었습니다. https://github.com/mikemaccana/python-docx/pull/67
이제 예외가 기본 제공되므로 해결 방법은 예외를 가져 오지 않는 것입니다.
docx.py
@@ -27,7 +27,12 @@
except ImportError:
TAGS = {}
-from exceptions import PendingDeprecationWarning
+# Handle PendingDeprecationWarning causing an ImportError if using Python 3
+try:
+ from exceptions import PendingDeprecationWarning
+except ImportError:
+ pass
+
from warnings import warn
import logging
당신은 설치 할 수있다 docx
, 없다python-docx
설치를 위해 이것을 볼 수 있습니다. python-docx
http://python-docx.readthedocs.io/en/latest/user/install.html#install
반응형
'program story' 카테고리의 다른 글
불변성이란 무엇이며 왜 걱정해야합니까? (0) | 2020.12.30 |
---|---|
GitHub 저장소 백업 (0) | 2020.12.30 |
Spring MVC @RestController 및 리디렉션 (0) | 2020.12.29 |
React-Router에서 onEnter가 호출되지 않았습니다. (0) | 2020.12.29 |
솔루션 탐색기 새로 고침 단추를 클릭 할 때 Visual Studio에서 폴더를 새로 고치지 않는 이유는 무엇입니까? (0) | 2020.12.29 |