IT skill/Python
-
Pandas를 다루다보면TypeError: Index(...) must be called with a collection of some kind, ' ' was passed 와 같은 에러를 마주할 수 있습니다. 이 경우에는 높은 확률로 DataFrame을 이렇게 만드셨을 가능성이 있습니다. import pandas as pdpd.DataFrame(element1, element2, element3) 이 부분을 다음과 같이 고쳐줍니다. import pandas as pdpd.DataFrame([element1, element2, element3]) 도움이 되셨다면 아무 광고나 클릭 한 번 부탁드립니다👍
TypeError: Index(...) must be called with a collection of some kind, ' ' was passedPandas를 다루다보면TypeError: Index(...) must be called with a collection of some kind, ' ' was passed 와 같은 에러를 마주할 수 있습니다. 이 경우에는 높은 확률로 DataFrame을 이렇게 만드셨을 가능성이 있습니다. import pandas as pdpd.DataFrame(element1, element2, element3) 이 부분을 다음과 같이 고쳐줍니다. import pandas as pdpd.DataFrame([element1, element2, element3]) 도움이 되셨다면 아무 광고나 클릭 한 번 부탁드립니다👍
2024.02.29 -
Albumentations 라이브러리를 import 하려 했는데 다음과 같은 에러가 발생하였습니다. libGL.so.1: cannot open shared object file: No such file or directorylibgthread-2.0.so.0: cannot open shared object file: No such file or directory 다음과 같이 우분투 터미널에서 libgl1-mesa-glx, libglib2.0-0을 설치해주면 됩니다. apt updateapt install libgl1-mesa-glxapt install libglib2.0-0 도움이 되셨다면 아무 광고나 클릭 한 번 부탁드립니다👍
Albumentations 라이브러리 import 에러Albumentations 라이브러리를 import 하려 했는데 다음과 같은 에러가 발생하였습니다. libGL.so.1: cannot open shared object file: No such file or directorylibgthread-2.0.so.0: cannot open shared object file: No such file or directory 다음과 같이 우분투 터미널에서 libgl1-mesa-glx, libglib2.0-0을 설치해주면 됩니다. apt updateapt install libgl1-mesa-glxapt install libglib2.0-0 도움이 되셨다면 아무 광고나 클릭 한 번 부탁드립니다👍
2024.02.26 -
albumentations 라이브러리에서 ToTensor를 쓰려면 albumentations.pytorch를 따로 import 하여 사용해야 합니다. 이런식으로 ToTensor를 사용하면 오류가 나게 됩니다.import albumentations as Atransform = A.Compose([A.pytorch.transforms.ToTensor()]) 왜 그런진 모르겠는데 이렇게 import를 해줘야 AttributeError: module 'albumentations' has no attribute 'pytorch' 에러가 발생하지 않더군요.🤔🤔import albumentations as Aimport albumentations.pytorch as APtransform = A.compose([..
AttributeError: module 'albumentations' has no attribute 'pytorch'albumentations 라이브러리에서 ToTensor를 쓰려면 albumentations.pytorch를 따로 import 하여 사용해야 합니다. 이런식으로 ToTensor를 사용하면 오류가 나게 됩니다.import albumentations as Atransform = A.Compose([A.pytorch.transforms.ToTensor()]) 왜 그런진 모르겠는데 이렇게 import를 해줘야 AttributeError: module 'albumentations' has no attribute 'pytorch' 에러가 발생하지 않더군요.🤔🤔import albumentations as Aimport albumentations.pytorch as APtransform = A.compose([..
2024.02.21 -
Status 확인# pythonprint(matplotlib.matplotlib_fname()) # matplotlib 설치된곳print(matplotlib.get_cachedir()) # 캐시폴더 나눔 글꼴 apt로 설치apt-get install fonts-nanum*fc-cache -fv matplotlib에 글꼴 추가cp /usr/share/fonts/truetype/nanum/Nanum* /첫번째에서_matplotlib설치된곳/mpl-data/fonts/ttf/rm -rf /첫번째에서_캐시폴더/* 위처럼 해봤지만 안되는 경우# 파이썬 켜고 아래 명령어 출력에서 Nanum 글꼴이 포함되어 있어야함.>> print([f.fname for f in matplotlib.font_manager.fontM..
matplotlib에서 한글 깨짐 해결방법 (ubuntu)Status 확인# pythonprint(matplotlib.matplotlib_fname()) # matplotlib 설치된곳print(matplotlib.get_cachedir()) # 캐시폴더 나눔 글꼴 apt로 설치apt-get install fonts-nanum*fc-cache -fv matplotlib에 글꼴 추가cp /usr/share/fonts/truetype/nanum/Nanum* /첫번째에서_matplotlib설치된곳/mpl-data/fonts/ttf/rm -rf /첫번째에서_캐시폴더/* 위처럼 해봤지만 안되는 경우# 파이썬 켜고 아래 명령어 출력에서 Nanum 글꼴이 포함되어 있어야함.>> print([f.fname for f in matplotlib.font_manager.fontM..
2024.01.04 -
Pytorch로 학습을 하다가 OSError: Truncated File Read 라는 에러를 마주했다. 이 에러는 Pillow로 손상된 이미지를 읽었을 때 발생한다. 아마 현재 코드가 pillow를 쓰고 있을 것이다. 데이터가 너무 많아서 뭐가 문제인지 몰라 이미지를 하나하나 다 읽어봐야 했다. 데이터가 몇십, 몇백만장 된다면 ray나 multiprocessing을 추천한다. 이미지를 다 읽어보고 이상한 데이터를 찾아내 이미지를 열어보니 아래와 같이 손상이 된 이미지였다. 역시 무작정 데이터셋을 신뢰하는건 나의 삽질에 큰 도움이 된다. 아래 함수를 잘 적용하면 손상된 이미지를 찾는데에 도움이 될 것이다. 이미지 경로를 glob으로 죄다 긁어서 함수에 넣어주면 된다. def truncated..
OSError: Truncated File ReadPytorch로 학습을 하다가 OSError: Truncated File Read 라는 에러를 마주했다. 이 에러는 Pillow로 손상된 이미지를 읽었을 때 발생한다. 아마 현재 코드가 pillow를 쓰고 있을 것이다. 데이터가 너무 많아서 뭐가 문제인지 몰라 이미지를 하나하나 다 읽어봐야 했다. 데이터가 몇십, 몇백만장 된다면 ray나 multiprocessing을 추천한다. 이미지를 다 읽어보고 이상한 데이터를 찾아내 이미지를 열어보니 아래와 같이 손상이 된 이미지였다. 역시 무작정 데이터셋을 신뢰하는건 나의 삽질에 큰 도움이 된다. 아래 함수를 잘 적용하면 손상된 이미지를 찾는데에 도움이 될 것이다. 이미지 경로를 glob으로 죄다 긁어서 함수에 넣어주면 된다. def truncated..
2023.12.06 -
현재 DISPLAY가 되지 않아서 cv2.imshow가 작동할 수 없다는 에러이다. 원격 서버 display가 되지 않는 환경이라면 display가 되게 세팅하거나 cv2.imshow를 사용하지 않는 것이 좋다. 원격 서버에서 GUI를 띄우는 방법은 https://beelinekim.tistory.com/15 글을 참고할 수 있다. reinstall 하면 해결될 수도 있다는 글도 있었지만 나 같은 경우에는 해결되지 않았다. 혹시 해결될 수도 있어 첨부한다. reinstall 해결방법1 pip uninstall opencv-python pip install opencv-python reinstall 해결방법2 pip uninstall opencv-python pip install opencv-python-..
qt.qpa.xcb: could not connect to display :0qt.qpa.plugin: Could not load the Qt platform plugin "xcb" ...현재 DISPLAY가 되지 않아서 cv2.imshow가 작동할 수 없다는 에러이다. 원격 서버 display가 되지 않는 환경이라면 display가 되게 세팅하거나 cv2.imshow를 사용하지 않는 것이 좋다. 원격 서버에서 GUI를 띄우는 방법은 https://beelinekim.tistory.com/15 글을 참고할 수 있다. reinstall 하면 해결될 수도 있다는 글도 있었지만 나 같은 경우에는 해결되지 않았다. 혹시 해결될 수도 있어 첨부한다. reinstall 해결방법1 pip uninstall opencv-python pip install opencv-python reinstall 해결방법2 pip uninstall opencv-python pip install opencv-python-..
2023.10.04