분명 numpy를 설치했는데 파이썬에서 numpy를 사용하려 하면 다음과 같이 AttributeError: module 'numpy' has no attribute ... 하는 에러가 뜰 때가 있습니다.

import numpy as np

print(np.__version__)
# AttributeError: module 'numpy' has no attribute '__version__'

 

이는 numpy가 설치는 되었지만 시스템에서 파이썬 라이브러리로 제대로 연결이 안 되어서 그렇습니다. 이럴 경우 맥에서 homebrew를 사용할 때를 기준으로

brew link --overwrite numpy

 

를 실행해주면 문제가 해결됩니다.

 

참조한 곳: https://github.com/Homebrew/homebrew-core/issues/15698#issuecomment-315730732

[파이토치 (PyTorch)] IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

 

0.5 이전 버전의 파이토치에서 작성된 코드를 0.5 이후 버전에서 돌리다 보면 위와 같은 에러가 날 때가 있습니다. 파이토치의 데이터 자료 구조가 바뀌어서 그렇습니다.

 

코드에서 변수.data[0] 인 부분을 변수.data 로 바꾸어주시면 해결됩니다.

 

참고한 곳: https://github.com/NVIDIA/flownet2-pytorch/issues/113#issuecomment-450802359

[안드로이드] No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android


안드로이드에서 사용되는 NDK 버전이 올라가면서 MIPS형 CPU에 대한 지원이 중단되었습니다. 그런데 build.gradle에 지정되어있는 gradle 버전이 낮으면 안드로이드 스튜디오가 MIPS에 대한 정보를 계속 찾으려고 하다가 위와 같은 에러를 내게 됩니다. 이럴 때에는 gradle 버전을 3.1.4 나 그 이상으로 설정해준 뒤 안드로이드 스튜디오를 껐다가 다시 실행하면 문제가 해결됩니다.


dependencies {

    classpath 'com.android.tools.build:gradle:3.1.4'

}



+ Recent posts