python 기초
-
pillow-simd install 에러python 기초 2023. 12. 18. 22:53
Pillow-SIMD 설치시 에러가 해결되지 않을때 아래의 경로에서 whl 파일을 바로 받아서 설치하니 해결 되었다. https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow-simd Archived: Python Extension Packages for Windows - Christoph Gohlke Archived: Python Extension Packages for Windows - Christoph Gohlke by Christoph Gohlke. Updated on 26 June 2022 at 07:27 UTC. This page provides 32 and 64-bit Windows binaries of many scientific open-source ex..
-
cupy util import errorpython 기초 2023. 11. 14. 21:51
opensource를 돌리는 과정에서 "No module named 'cupy.util' " 와 같은 에러가 발생했다. 아래를 참조해보면, cupy 버전이 바뀌면서 생긴 문제같다. cupy._util로 해당 코드를 바꾸면 동작한다고 한다. https://stackoverflow.com/questions/66421447/chainer-no-module-named-cupy-util Chainer: No module named 'cupy.util'` I am getting desperate with Chainer because I'm not able to use it with GPU for about a week now. The error I am getting: RuntimeError: CUDA enviro..
-
pip install cupy errorpython 기초 2023. 11. 14. 21:45
cupy를 설치하는 과정에서 legacy-install-failure 와 같은 메세지가 발생했다. 검색해보니 cuda 버전에 맞추어 설치를 해야 하는것 같다. 아래의 reference에 따라, 내 PC의 cuda 버전(10.2)에 맞는 command로 설치하니 해결되었다. https://docs.cupy.dev/en/stable/install.html Installation — CuPy 12.2.0 documentation Installation Requirements NVIDIA CUDA GPU with the Compute Capability 3.0 or larger. CUDA Toolkit: v10.2 / v11.0 / v11.1 / v11.2 / v11.3 / v11.4 / v11.5 / v11...
-
한글 url 변환python 기초 2023. 1. 25. 18:40
pandas로 github에 있는 data를 읽어올때, 한글 url이 있으면 불러오지 못하는 문제를 확인했다. url에는 한글이 인코딩 되어서 그렇다고 한다. (참고 : https://nov19.tistory.com/111) 아래와 같이 urllib을 이용해서 한글을 포함한 url도 변환할 수 있다. import pandas as pd try: data_df = pd.read_csv('https://raw.githubusercontent.com/Namseop/stock/main/230120/naver_종목_090405.csv', encoding="euc-kr") except: print("data load error") import urllib data_df = pd.read_csv('https://ra..
-
python repr eval 사용python 기초 2023. 1. 24. 12:43
python의 str과 repr 함수가 비교되는 경우가 있는데 검색해보니 실제로 그 용도나 성격이 많이 다름을 알 수 있다. 찾아보고 이해한 바에 따르면 아래와 같다. str() repr() 용도 데이터를 string으로 변환 해당 데이터를 다시 생성할 수 있는 명령어 코드를 돌려보며 감을 잡아보았다. import datetime print("string 의 경우") cur_time=datetime.datetime.now() str_time = str(cur_time) print(str_time) print("repr 의 경우") repr_time = repr(cur_time) print(repr_time) print(eval(repr_time)) 위와 같이 사용할 때, string의 경우 자연스럽게 c..
-
type annotationpython 기초 2023. 1. 24. 12:13
python / matlab과 같은 동적 타입 언어를 주로 쓰다보면, 만들때는 응당 그러려니 하고 만들었던 함수가 나중에는 헷갈리는 경우가 많다. 주석도 중요하지만, type annotation 또한 중요해보인다. def int_mul(a:int,b:int): return a*b def float_mul(a,b): return a*b print(int_mul.__annotations__) print(float_mul.__annotations__) 위의 int_mul 함수와 같이 입력 변수 뒤에 :type 으로 input에 대한 annotation을 해주면 된다. 이렇게 되면 아래에서 함수명.__annotations__ 를 통해 호출해서 각 변수의 type을 알수 있다. 협업시 중요한 기능 중 하나라 할 ..