본문 바로가기

Python8

python - ubuntu에서 python 인터프리터 변경 방법 #버전 확인 python -V #경로 확인 which python #실행파일 찾기 ls /usr/bin/ | grep python #선택 추가 sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 선택 sudo update-alternatives --config python 2020. 11. 13.
python - TypeError: 'dict' object is not callable 해결법 post 전송 한 값을 json에 담아서 리턴 할 경우 발생한다. 이는 이렇게 해결할 수 있다. from functools import wraps def as_json(f): @wraps(f) def decorated_function(*args, **kwargs): res = f(*args, **kwargs) res = json.dumps(res, ensure_ascii=False).encode('utf8') return Response(res, content_type='application/json; charset=utf-8') return decorated_function 위에 코드를 작성 후 전송 받는 api에 아래와 같이 데코를 달아주면 된다. 2020. 11. 13.
python - from PIL import Image Error 에러 해결법 연결 된 인터프리터가 아닌 다른 인터프리터에 라이브러리가 다운 됐을 확률이 있다. 라이브러리를 설치 한 후, 인터프리터를 변경 했을 경우 해당 라이브러리를 삭제 후 다시 설치하면 된다. pip uninstall Pillow pip uninstall Image pip install Pillow pip uninstall Image 2020. 11. 13.
python3- ubuntu에 apache2와 Flask 연동하기 환경은 ubuntu 18.04를 사용 1.아파치 다운로드 1. apt 업데이트 및 아파치2 다운로드 sudo apt-get update && sudo apt-get install apache2 2. 파이썬3 다운에 필요한 파일 설치 sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \ libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev cd /opt 2-1 파이썬3 다운 및 압축 풀기 //버전 확인 중요 sudo wget https://www.python... 2020. 11. 11.