본문 바로가기

error4

[PyCharm] SyntaxError: non-utf-8 code starting with '\xfe' PyCharm에서 한글 관련 개발을 할 때 다음과 같은 에러를 보는 경우가 있다. SyntaxError: non-utf-8 code starting with '\xfe' 인터넷에서 뒤져보면 아래와 같은 encoding 명령을 코드 맨 위에 넣으라고 한다. # -*- coding: utf-8 -*- 그런데 이렇게 해도 같은 에러가 계속될 때는 프로그램 파일이 다른 encoding으로 되어있기 때문이다. 따라서, 다음과 같이 파일을 editor에서 읽어 온 다음, main menu의 File > File Properties > File Encoding 에서 UTF-8 같은 것으로 변경해주면 된다. 2024. 3. 11.
Anaconda의 Jupyter Notebook에서 ModuleNotFoundError가 발생했을 때 Anaconda의 conda environment 에서 Jupyter notebook으로 실험할 때 모듈을 설치 했는데도 그 모듈을 import하려고 하면 ModuleNotFoundError가 발생하는 경우가 있다. pip install A_module # A_module 설치 & 성공 import A_module # ----> ModuleNotFoundError 에러 발생 이 경우는 root 환경의 jupyter notebook을 사용하여 conda environment의 경로가 인식되지 않아서 이다. 이를 해결하려면 conda environment 안에서 jupyter를 install하고 jupyter notebook을 사용하면 된다 (myenv)$ conda install jupyter (myenv.. 2022. 10. 28.
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.HalfTensor) should be the same 아직 이 error의 원인은 모른다. 다만, 아래 처럼하면 일단 error가 나는 것을 방지할 수 있다. from torch.cuda.amp import autocast with autocast(): outputs = model.forward(tensor) 2021. 3. 15.
ImportError: cannot import name 'PILLOW_VERSION' torchvision과 Pillow를 같이 쓸 때 이런 에러가 나는 경우가 있다. 인터넷을 뒤져보면 pillow의 버전을 6.1로 낮추면 해결된다는 얘기가 있는데 내 경우는 해결이 안됐다. 내 경우엔 torchvision/transforms/functional.py 파일에서 'from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION' 을 하고 있었다. 한편 PIL/__init__.py 파일에는 # VERSION was removed in Pillow 6.0.0. # PILLOW_VERSION was removed in Pillow 7.0.0. # Use __version__ instead. __version__ = _version.__version__.. 2020. 2. 3.