반응형

오랜만에 AWS EC2에 Python을 설치하는데 아래와 같은 에러가 발생한다.

 

$ pyenv install 3.6.9
Downloading Python-3.6.9.tar.xz...
-> https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz
Installing Python-3.6.9...

BUILD FAILED (Amazon Linux AMI 2018.03 using python-build 1.2.13-4-g6563b64d)

Inspect or clean up the working tree at /tmp/python-build.20190901070310.7044
Results logged to /tmp/python-build.20190901070310.7044.log

Last 10 log lines:
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/python-build.20190901070310.7044/Python-3.6.9':
configure: error: no acceptable C compiler found in $PATH

 

아래와 같이 gcc 설치로 해결하자. 

$sudo yum install gcc

반응형

반응형

다운로드 받을 파일 타입(Mimetype) 구분 방법

import mimetypes

mimetypes.guess_type('test.png')  # return ('image/png', None)

 

 

    import mimetypes
    import urllib
    
    
    file_name = urllib.parse.quote(file_info.file_name.encode('utf-8'))

    if os.path.exists(file_path):
        with open(file_path, 'rb') as fh:
            response = HttpResponse(fh.read(), content_type=mimetypes.guess_type(file_path)[0])
            response['Content-Disposition'] = 'attachment;filename*=UTF-8\'\'%s' % file_name
            return response

 

반응형

+ Recent posts