AsciiTable 라이브러리란?
- terminal에서 표를 나타낼 수 있게 해주는 라이브러리
- 간단하게 텍스트를 깔끔하게 표현할 수 있다
에러 메세지 & 발생 환경
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [17 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-yjk49w9n/asciitable_e8c051a8317d4a6ea92df4539cd8c6e7/setup.py", line 30, in <module>
from asciitable.version import version
File "/tmp/pip-install-yjk49w9n/asciitable_e8c051a8317d4a6ea92df4539cd8c6e7/asciitable/__init__.py", line 29, in <module>
from asciitable.core import (has_numpy,
File "/tmp/pip-install-yjk49w9n/asciitable_e8c051a8317d4a6ea92df4539cd8c6e7/asciitable/core.py", line 735, in <module>
class NumpyOutputter(BaseOutputter):
File "/tmp/pip-install-yjk49w9n/asciitable_e8c051a8317d4a6ea92df4539cd8c6e7/asciitable/core.py", line 768, in NumpyOutputter
default_converters = [convert_numpy(numpy.int),
File "/opt/conda/lib/python3.10/site-packages/numpy/__init__.py", line 324, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
- Python 3.10.13
- numpy 1.26.3
- AsciiTable을 설치할 때 이런 에러가 발생했다
해결 과정 (해결 실패)
- 버전 문제로 발생하는 에러인 것 같아서 아래와 같이 최신 버전으로 설치해보았다
# pip install --upgrade numpy
# pip install --upgrade AsciiTable
대체 방법 : PrettyTable
- AsciiTable과 같은 역할을 하는 PrettyTable 라이브러리를 설치하여 사용하였다
PrettyTable 설치
# pip install PrettyTable
사용 방법
from prettytable import PrettyTable
table = PrettyTable()
table.field_names = ["이름", "나이"]
table.add_row(["nahye", 26])
table.add_row(["henna", 30])
print(table)
+-------+------+
| 이름 | 나이 |
+-------+------+
| nahye | 26 |
| henna | 30 |
+-------+------+