Backend/๐ Python(17)
-
[Open AI API ์๋ฌ] ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3
FastAPI ๋ก ์ฐํผํฐ import ํ ๋ ๋ฐ์ํ ์๋ฌ FastAPI ๋ด๋ถ์ ์ค์น๋ urllib3 v2.0 ์ด OpenSSL 1.1.1+ ๋ฒ์ ๋ง ์ง์ํ๋ค๊ณ ํ๋ค. Error message ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3. See: https://github.com/urllib3/urllib3/issues/2168 ๊ทธ๋ผ ์ด๋ป๊ฒ ํ ๊น? ์๋ฌ๋ฅผ ํด๊ฒฐํ๋ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ด ์์ง๋ง, ํ์๋ ๊ฐ๋จํ urllib3์ ๋ฒ์ ์ 2.0๋ณด๋ค ์๋๋ก ๋ค์ด๊ทธ๋ ์ด๋ ํ๋ค ํด๊ฒฐ pip uninstall urllib3 pip install 'urllib3
2023.05.28 -
[Error]Python ๊ฐ์ํ๊ฒฝ ์ค์น configure: error: Unexpected output of 'arch' on OSX
ํจ์คํธ ์บ ํผ์ค ๋ ๋ ๋ : ๋์ฉ๋ ์๋น์ค๋ฅผ ์ํ ์ํคํ ์ฒ with Redis by ๊ฐ๋๋ช ์์ ์ค์ต ์ค ๋ฐ์ํ ์๋ฌ ์๋ฌ ๋ฉ์์ง configure: error: Unexpected output of 'arch' on OSX make: *** No targets specified and no makefile found. Stop. ํด๊ฒฐ m1 apple silicon issue ๋ก python version ์ 3.9.1 ๋ก ์ ๊ทธ๋ ์ด๋. pyenv install 3.9.1 ref : https://www.codeit.kr/community/threads/31708
2022.10.03 -
์ต๊ทผ ํ์ด์ฌ PS ํ๋ฉด์ ๋ฐฐ์ด ๊ฒ
dict ์ fromkeys() ๋ฉ์๋ - ๋์ ๋๋ฆฌ ์์ฑ ์, ์ด๋ฏธ key ๊ฐ์ด ์ ํด์ง ๊ฒฝ์ฐ ํธ๋ฆฌํ๊ฒ ๋์ ๋๋ฆฌ๋ฅผ ์์ฑํ ์ ์๋ค. - seq : ๋์ ๋๋ฆฌ์ key ๊ฐ์ด ๋ iterable ๋ก, ์ฆ dictionary ์ key ๋ชฉ๋ก์ด๋ค. - value : seq ์ ๊ฐ key ์ ํ ๋น๋ value (๊ฐ) ์๋ฏธ # ์ ์ @staticmethod # known case def fromkeys(*args, **kwargs): # real signature unknown """ Create a new dictionary with keys from iterable and values set to value. """ pass # ์ฌ์ฉ๋ฒ value = 0 seq = [1, 2, 3] dictionary = dict...
2022.05.05 -
Django CBV (3) - DetailView
views.py from django.contrib.auth.models import User from django.views.generic import DetailView class AccountDetailView(DetailView): model = User context_object_name = 'target_user' # target์ด ๋๋ user์ ์ ๋ณด๋ฅผ ๋ณด์ผ ์ ์๋๋ก template_name = "detail.html" User์ detailํ ์ ๋ณด๋ฅผ ๋ณด๊ณ ์ถ์ ๋ DetailView class๋ฅผ ์์ ๋ฐ์ต๋๋ค. model ์ ์ญ์ ๋ฏธ๋ฆฌ ์ ์๋ User ๋ชจ๋ธ์ ๊ฐ์ ธ์ต๋๋ค. context_object_name = 'target_user'๋ ์ง์ ํด์ค์๋ค . ์ด๋ ๊ฒ target_user๋ฅผ ํ ๋นํ..
2021.05.23 -
Django CBV (2) - ๋ก๊ทธ์ธ, ๋ก๊ทธ์์ ๊ตฌํ
Urls.py ์ฒซ์ค์ from django.contrib.auth.views import LogoutView, LoginView ์์ LoginView ์ LogoutView ๋ผ๋ ํด๋์ค๋ฅผ ์์๋ฐ์์์ ํ์ธํ ์ ์์ต๋๋ค. from django.contrib.auth.views import LogoutView, LoginView from django.urls import path from account.views import AccountCreateView, hello_world app_name = "account" urlpatterns = [ path('hello_world', hello_world, name='hello_world'), path('create/', AccountCreateView.as..
2021.05.23 -
Django CBV (1) - ํ์๊ฐ์
FBV(function based view)๊ฐ ์๋ CBV(class based view)๋ก ํ์๊ฐ์ ์ ์์ฑํ๋ฉด, Django๊ฐ ์ ๊ณตํ๋ class๋ฅผ ์์๋ฐ๊ธฐ ๋๋ฌธ์ ๋ ๊ฐ๊ฒฐํ ์ฝ๋๋ก ์์ฑํ ์ ์์ต๋๋ค. Views.py from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from django.views.generic import CreateView from django.urls import reverse_lazy class AccountCreateView(CreateView): model = User form_class = UserCreationForm success_url = ..
2021.05.23 -
Django Bootstrap4 ์ฐ๋
1. ์ฐ์ Bootstrap ๊ณต์ํํ์ด์ง์์ CSS CDN์ copy ํฉ๋๋ค. https://getbootstrap.com/docs/5.0/getting-started/introduction/ Introduction Get started with Bootstrap, the worldโs most popular framework for building responsive, mobile-first sites, with jsDelivr and a template starter page. getbootstrap.com copy ํ css cdn ์ ์ฅ๊ณ ํ ํ๋ฆฟ ๋ด๋ถ์ ๋ถ์ฌ๋ฃ๊ธฐ ํด์ค๋๋ค. 2. bootstrap4 library๋ฅผ ๋ค์ด๋ก๋ ๋ฐ๊ฒ ์ต๋๋ค. terminal์ pip install django-bootst..
2021.05.23 -
ํ์ด์ฌ ๋ฉ์๋ ์ค๋ฒ๋ผ์ด๋ฉ, ์ค๋ฒ๋ก๋ฉ
๋ฉ์๋ ์ค๋ฒ๋ผ์ด๋ฉ ์ค๋ฒ๋ผ์ด๋ฉ์ ๋ถ๋ชจ ํด๋์ค์ ๋ฉ์๋๋ฅผ, ์์ ํด๋์ค์์ ์ฌ์ ์ ํ์ฌ ์ฌ์ฉํ๋ ๊ฒ์ ์๋ฏธํ๋ค. ์๋ฅผ ๋ค์ด ๋ถ๋ชจํด๋์ค์์ add()๋ผ๋ ๋ฉ์๋๋ 2๊ฐ์ ์ธ์๋ฐ์ ๋ํ ์ ์์ง๋ง, ์์ ํด๋์ค์ add() ๋ฉ์๋๋ ์ค๋ฒ๋ผ์ด๋ฉ๋์ด 3๊ฐ์ง์ ์ธ์๊น์ง ๋ฐ๋๋ก ์ฌ์ ์ ํ ์ ์๋ค. ์๋ธํด๋์ค(์์)์์ ์ํผ(๋ถ๋ชจ)ํด๋์ค๋ฅผ ํธ์ถ ํ ์ฌ์ฉ ๋ฉ์๋ ์ฌ ์ ์ ํ ์ฌ์ฉ๊ฐ๋ฅ ๋ถ๋ชจํด๋์ค์ ๋ฉ์๋๋ฅผ ์ถ์ํ ํ ์ฌ์ฉ๊ฐ๋ฅ (๊ตฌ์กฐ์ ์ ๊ทผ ๊ฐ๋ฅ) ํ์ฅ ๊ฐ๋ฅ + ๋คํ์ฑ(๋ค์ํ ๋ฐฉ์์ผ๋ก ๋์ -> ๋ถ๋ชจ์์ ๋ฉ์๋ ํ๋๋ฅผ ๋ง๋ค์ง๋ง,์ฌ์ฉํ๋ ์์์ ๋ฐ๋ผ ๋ค์ํ๊ฒ ์ฌ์ฉ๋ ์ ์๋ค) ๊ฐ๋ ์ฑ ์ฆ๊ฐ, ์ค๋ฅ๊ฐ๋ฅ์ฑ ๊ฐ์, ๋ฉ์๋ ์ด๋ฆ ์ ์ฝ(๋ถ๋ชจ๊ฐ ๋ฉ์๋ ์ด๋ฆ์ ์ด๋ฏธ ์ ์ํด๋จ๊ธฐ์) dir(),_dict_ ๊ฐ์ฒด ๋ด๋ถ ๊ฒ์ฌ ๋ฉ์๋ dir() :..
2021.05.18 -
ํ์ด์ฌ lambda, filter, reduce
์ํ์คํ: ์ ์ฒ๋ฆฌ์ reduce, map, filter ์ฌ์ฉ (3ํ์ ) ์ต๋ช ํจ์ Lambda ํจ์๋ ํํ ์ฐ๋ฆฌ๊ฐ ์๋ ์ผ๋ฐํจ์์ ์ต๋ช ํจ์๋ก ๋๋ ์ ์๋ค. ์ต๋ช ํจ์๋ ์ผ๋ฐํจ์์ ๋ฌ๋ฆฌ ํธ์ถ๋ ํ ์ฆ์ ์๋ฉธ๋๋ค. (์ผ๋ฐํจ์๋ ๋ฐํ ํ์๋ ๋ฉ๋ชจ๋ฆฌ ์ก์๋จน๋๋ค) ์ต๋ช ํจ์๋ ์ผ๋ฐํจ์๋ณด๋ค ๊ฐ๊ฒฐํ๊ฒ ์์ฑํ์ฌ ์ฌ์ฉํ ์ ์๋ค. ์ด๋ฌํ ํน์ฑ์ผ๋ก lambda(์ต๋ช ํจ์)ํจ์๋ ๊ฐ๊ฒฐํ๊ณ ์ผํ์ฑ์ผ๋ก ์ฌ์ฉํ ํจ์ ์์ฑ์ ์ฌ์ฉ๋๋ค. # ์ผ๋ฐํจ์ def func_name(a, b): return a + b # ์ต๋ช ํจ์ total = lambda a, b: a + b # ์ต๋ช ํจ์๋ ํจ์๋ช ์ ํ๋๋ผ ๊ณจ ์ํ ์ผ๋ ์๋ค. (๋ง ๊ทธ๋๋ก '์ต๋ช ' ํจ์) lambda ํจ์ ์์ 1~10๊น์ง์ ์์ฐ์๋ฅผ ๊ฐ๊ฐ ์ ๊ณฑํ์ฌ ๋ฆฌ์คํธ์ ์ ์ฅํด..
2021.05.18