728x90
반응형
1. 필수 패키지 설치 1
apt-get install libssl-dev
apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev
위와 같이 필요한 패키지를 설치하고 파이썬을 설치해야 정상 설치가 된다.
1-1. 필수 패키지 설치 2
sudo apt-get install libssl1.0
필자는 추가로 위 패키지도 설치해주었다.
위 패키지를 설치하지 않고 파이썬을 설치하고나서 pip 를 설치할 때 자꾸 아래와 같은 에러가 발생한다.
이것 때문에 2시간 삽질함, 아래는 삽질 기록이다.
~$ curl https://bootstrap.pypa.io/get-pip.py | python3.5
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1884k 100 1884k 0 0 3709k 0 --:--:-- --:--:-- --:--:-- 3702k
Traceback (most recent call last):
File "<stdin>", line 24244, in <module>
File "<stdin>", line 199, in main
File "<stdin>", line 82, in bootstrap
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 896, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1139, in find_spec
File "<frozen importlib._bootstrap_external>", line 1115, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1096, in _legacy_get_spec
File "<frozen importlib._bootstrap>", line 444, in spec_from_loader
File "<frozen importlib._bootstrap_external>", line 533, in spec_from_file_location
File "/tmp/tmpes20_bph/pip.zip/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
위와 같은 에러를 치면 저 문법이 Python 3.5 와 호환되지 않아서
Python2.7 용 get-pip.py 를 설치해서 Python 3.5 를 설치하라고 나오는데, 그렇게 할 경우 또 아래와 같은 에러가 발생된다.
~$ python3.5 get-pip.py
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
ERROR: Could not find a version that satisfies the requirement pip<21.0
ERROR: No matching distribution found for pip<21.0
2. 원하는 파이썬 버전의 다운로드 링크 복사하기
3. 다운로드 및 압축풀기
$ wget <download link>
$ tar -zxvf Python-3.5.2.tgz
4. 설치하기
$ cd Python-3.5.2
$ ./configure
$ make
$ sudo make install
아래와 같이 뜨면 성공
Requirement already up-to-date: setuptools in /usr/local/lib/python3.5/site-packages/setuptools-33.1.1-py3.5.egg
Collecting pip
Installing collected packages: pip
Successfully installed pip-8.1.1
만약에 python 3.5 의 pip 를 이용하여 패키지를 설치하려는데, 아래와 같은 에러가 난다면
Traceback (most recent call last):
File "/usr/local/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/seohee/.local/lib/python3.5/site-packages/pip/__main__.py", line 21, in <module>
from pip._internal.cli.main import main as _main
File "/home/seohee/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
아래와 같이 다시 python 3.5 버전에 맞게 다시 설치해주도록 하자
$ curl https://bootstrap.pypa.io/3.5/get-pip.py --output get-pip.py
$ python3 get-pip.py
참고자료 1 : bablabs.tistory.com/19
참고자료 2 : stackoverflow.com/questions/65896334/python-pip-broken-wiith-sys-stderr-writeferror-exc
728x90
반응형
'Programming > Python' 카테고리의 다른 글
[Python] google images download 이용하여 구글 검색 이미지 저장하기 (0) | 2021.05.20 |
---|---|
[Python] argparse(Argument Parser) 에서 boolean 값 받기 (0) | 2021.01.14 |
[Python] pytube 이용하여 Youtube 영상 저장하기 (0) | 2020.12.28 |
[Python] GPU 지정하여 Python 코드 실행하기 (0) | 2020.11.20 |
[Python] 파일명 추출, 디렉토리 경로 추출 (3) | 2020.11.20 |