아래와 같은 오류가 발생시
ImportError: cannot import name 'np_utils' from 'tensorflow.keras.utils'
패키지가 아래와 같이 되어 있다면
from tensorflow.keras.utils import np_utils
tesorflow.python.keras.utils 로 변경 해 주도록 하자.
from tensorflow.python.keras.utils import np_utils아래와 같은 오류가 발생시
ImportError: cannot import name 'np_utils' from 'tensorflow.keras.utils'
패키지가 아래와 같이 되어 있다면
from tensorflow.keras.utils import np_utils
tesorflow.python.keras.utils 로 변경 해 주도록 하자.
from tensorflow.python.keras.utils import np_utilstensorflow 소스 실행시 아래와 같은 에러가 발생하면
Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)
OSX 환경이라면 아래 커맨드를 실행해주자.
!!!중요 Python 버전은 자신의 환경에 맞게 고쳐서 실행하자 !!!
/Applications/Python\ 3.7/Install\ Certificates.command
아니면 해당 소스코드에 아래 내용을 넣어줘도 된다.
import requests
requests.packages.urllib3.disable_warnings()
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
아니면 아래 링크를 참고해서 문제를 해결 하도록 하자.
tensorflow v2 에서 v1 버전 소스코드를 실행하면 에러가 발생한다.
AttributeError: module 'tensorflow' has no attribute 'Session'
tensorflow v1에서 작성된 코드를 v2환경에서 실행했을때 발생하는 경우인데
import tensorflow as tf
아래 처럼 변경 및 추가를 해주면 실행 가능
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()tensorflow를 활용한 python 코드 실행시 아래와 같은 메세지가 나온다면
This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
실행 소스 상단에 아래 소스 두줄만 넣어 주면 된다.
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
Tensorflow는 TF_CPP_MIN_LOG_LEVEL 이라는 환경변수를 통해 로깅을 제어 할 수 있으므로 설정을 통해 해결 가능하다.
기본값은 0(모든 로그 표시) , 1(INFO 로그 필터링), 2(WARNING 로그 필터), 3(ERROR 로그 필터)
import os
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
hellow = tf.constant('hellow' )
print(hellow)brew install libmagic
맥환경에서 Unable to revert mtime: /Library/Fonts 메세지 발생시 해당 libmagic 설치로 해결 할수 있다.
AttributeError: 'DataFrame' object has no attribute 'ix'
pandas 함수에서 ix가 삭제되고 .loc , .iloc 가 추가되었다.
ix 함수를 loc 나 iloc로 바꿔주자.
위에 같은 문제가 발생하면 api 문서를 찾아 보는 습관을 가져야 겠다.
pandas doc 참고해 보도록 하자
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/Users/guda/dev/python/.venv/lib/python3.7/site-packages/PIL/MpoImagePlugin.py'
Check the permissions.
맥북에서 Visual Studio Code를 이용해 Python 을 개발하다 보니 여러가지 좌충우돌 상황을 격게 된다.
위와 같은 에러 발생시 간단하게 해결이 가능하다.
sudo 명령어를 맨앞에 넣어주면 된다. 권한 문제에는 역시 sudo!!
sudo pip3 install -U scikit-learn scipy matplotlib scikit-image
PhantomJS의 경우 더이상 업데이트를 하지 않는다고 한다.
이로 인해 Selenium 최신 버전의 경우 PhantomJS를 포함하지 않는다.
그로인해 아래 코드가 정상작동하지 않는다.
browser = webdriver.PhantomJS()
이를 해결하기 위한 방안은 설치된 Selenium의 버전을 다운그레이드 하는 방법이다.
기존 설치된 Selenium을 삭제하고 버전을 지정하여 재설치 하자.
pip uninstall selenium
pip install selenium==2.48.0
이것 때문에 한참 삽질을 했다. ㅡㅡ;
한글로 된 자료가 없어 정리한다. 참고하여 삽질하는 일이 없기를 바라며.
VScode에서 opencv로 웹캠 접근시 아래와 같이 메세지가 뜨며 실행되지 않는다.
VScode에서 웹캠 접근시 권한 문제로 실행되지 않는 듯 하다.

아래 링크를 참조해서 해결했다.
https://stackoverflow.com/questions/52634009/opencv-python-scripts-mac-aborts
OpenCV Python Scripts Mac "aborts"
So I'm just trying to run the basic OpenCV program import numpy as np import cv2 cap = cv2.VideoCapture(0) while(True): # Capture frame-by-frame ret, frame = cap....
stackoverflow.com
VSCode 실행 후
1. cmd+shift+p
2."shell command: Install code in PATH" 타이핑 후 선택
3. vscode 종료
4. mac 터미널에서 "sudo code"로 vscode 구동
파이선 프로그램 실행 시 오류 없이 실행 되는 것을 확인 할 수 있다.
Mac VSCode에서 파이썬 실행시 아래 링크를 참조 하면 쉽게 환경을 구성할 수 있다.
https://code.visualstudio.com/docs/python/python-tutorial
Get Started Tutorial for Python in Visual Studio Code
A Python hello world tutorial using the Python extension in Visual Studio Code (a great Python IDE like PyCharm, if not the best Python IDE)
code.visualstudio.com