글

라벨이 python인 게시물 표시

mac python 3.9 에서 pytables 설치

이미지
 pytables 설치시 hdfs 설치와 관련된 오류 메시지와 함께 설치가 중지되었다. https://github.com/freqtrade/freqtrade/issues/4162  에서 제시된 솔루션으로 설치 성공: pip install cython brew install hdf5 brew install c-blosc export HDF5_DIR=/usr/local/ export BLOSC_DIR=/usr/local/ pip install tables

GCP Cloud Function 배포 오류 문제 (python)

이미지
다음과 같이 cloud function 의 hello world quickstart  를 배포만 하려고 하는데 퍼미션 에러가 발생했다: $ gcloud functions deploy hello_get --runtime python39 --trigger-http --allow-unauthenticated ERROR: (gcloud.functions.describe) ResponseError: status=[403], code=[Ok], message=[Permission denied on resource project XXX.] 문제는 service account 쪽이 아닌 cloud build 쪽의 권한이 제대로 설정되지 않아서 발생한 문제였다: 문서상으로는 functions 배포에 cloud build 가 관여하는 내용이 없었기 때문에 한참 헤매었다. cloud build 의 설정 메뉴에서 cloud functions, app engines, 서비스 계정 등등 필요할 것 같은 서비스 상태를 설정하고 실행했다. $ gcloud functions deploy hello_get --region=asia-northeast3 --runtime python39 --trigger-http --allow-unauthenticated Deploying function (may take a while - up to 2 minutes)...failed. ERROR: (gcloud.functions.deploy) OperationError: code=7, message=Build failed: service account "XXXXX@cloudbuild.gserviceaccount.com" has insufficient permission to execute the build on project "XXXXX" com.google.net.rpc3.client.RpcClientException: <eye3 title='/ArgoAdmi...

pandas.read_csv() 에서 왠만하면 컬럼타입을 지정하자

다음과 같은 파일이 있다 : CODE,DATE,TIME,OPEN,HIGH,LOW,CLOSE,VOLUME 000020,20190502,901,9770,9790,9770,9790,98 000020,20190502,902,9830,9830,9830,9830,1 000020,20190502,903,9830,9850,9830,9850,1 그렇다. 이건 하루치 분봉 데이터를 모은 것으로, 46M 정도의 크기이다. 이를 다음과 같이 나이브하게 로드했다: >>> df=pd.read_csv('test.csv') sys:1: DtypeWarning: Columns (0) have mixed types. Specify dtype option on import or set low_memory=False. 분봉이므로 9시 1분부터 오후 3시 30분까지 383개 의 데이터가 존재한다. 그런데 다음과 같은 명령으로 조회시 특정 컬럼에 대해서만 개수가 모자라는 현상이 있었다 : >>> df[df['CODE']=='071970'] 262140  071970  20190502  1029  5170  5170  5170   5170       1 262141  071970  20190502  1030  5170  5170  5170   5170       0 262142  071970  20190502  1031  5140  5140  5130   5140     177 262143  071970  20190502  1032  5140  5140  5130...

pip install 시 OSError: [Errno 13] Permission denied: '/lib'

homebrew 에서 python 을 깔고 pip 로 인스톨하려는데 Permission denied 에러가 자꾸 나는데, 환경 변수도 특별히 셋업된 게 없어서 한참을 삽질함했다. Exception: Traceback (most recent call last):   File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main     status = self.run(options, args)   File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run     prefix=options.prefix_path,   File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install     **kwargs   File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install     self.move_wheel_files(self.source_dir, root=root, prefix=prefix)   File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files     isolated=self.isolated,   File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 344, in move_wheel_files ...

Flask-OAuth2-Login example 연동시 401 Unauthorized Error 날 때

Flask-OAuth2-Login 의 예제를 이용해 구글 OAuth2 인증을 돌려보는데 자꾸 401 Unauthorized 에러가 난다. 코드를 이래저래 따라가다 이유를 알았다. OAUTHLIB_RELAX_TOKEN_SCOPE 이라는 환경변수가 설정되어 있지 않으면 oauthlib ( https://github.com/idan/oauthlib/blob/62ee76f22e8b0a53b2eda4a88e2891ed6578083b/oauthlib/oauth2/rfc6749/parameters.py )에서 Warning 을 던져서 profile 조회가 제대로 되지 않는 것. 다음과 같이 환경 변수를 설정하니 문제 해결 : export OAUTHLIB_RELAX_TOKEN_SCOPE=1