本文目標
介紹Mac環境下,安裝Python 3.8及一些依賴包.
前提條件
具備翻出去的能力
步驟
1.下載Python 3.8
https://www.python.org/ftp/python/3.8.5/python-3.8.5-macosx10.9.pkg
- 安裝並配置環境變量
vi .bash_profile
增加如下行:
export PATH=/usr/local/bin/:$PATH
source .bash_profile
- 安裝依賴包
根據具體需要安裝,下面是給出的樣例:
pip3 install lxml
pip3 install requests
pip3 install pathlib
緣起
之所以寫文本,是之前的環境下執行pip3下載依賴包時報如下錯誤:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting lxml
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/lxml/
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/lxml/
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/lxml/
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/lxml/
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/lxml/
Could not fetch URL https://pypi.org/simple/lxml/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/lxml/ (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 lxml (from versions: none)
ERROR: No matching distribution found for lxml
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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