windows
環境
anaconda
anaconda是python的一個開發集成環境,裏面集成了很多常用的包,安裝即用,十分方便,唯一的缺點就是體積太大。
下載
miniconda
miniconda是anaconda的精簡版,去掉了一部分包,體積縮小。
下載
python
原生的python環境,都是基礎包,按需安裝package。
下載
pip
一般來說,上面的環境安裝好後,都集成了pip,版本可能不是最新的,但也能用。也可以直接用pip install -U pip
命令升級。也可下載安裝文件。提供兩種格式的安裝文件,whl需要用pip install xxx.whl
安裝。tar.gz需要解壓,然後在目錄下使用python install setup.py
安裝。
下載
配置
更換源
使用命令獲取pip.ini
文件的查找位置,pip -v config list
。
如果有就修改其內容。如果沒有,就在其中一個路徑下新建文件並編輯內容。
這是改成了清華源的配置文件,可以根據自己的喜好調整。
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
linux
以Ubuntu爲例
下載python安裝文件 wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
解壓 tar -xzvf Python-3.7.8.tgz
安裝pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
安裝pip會出現的問題
卸載python
- 卸載python2.7
sudo apt-get remove python2.7
- 卸載python2.7及其依賴
sudo apt-get remove --auto-remove python2.7
- 消除python2.7
sudo apt-get purge python2.7 or sudo apt-get purge --auto-remove python2.7
設置python爲默認(避免使用python3而是直接用python)
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150