1、anaconda換源
conda config --add channels https:
//mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --
set
show_channel_urls yes
2、創建一個名為python36的環境,指定Python版本是3.6
conda create --name python36 python=3.6
3、激活某個環境
activate python36 # for Windows
source activate python36 # for Linux & Mac
deactivate python36 # for Windows
source deactivate python36 # for Linux & Mac
4、 刪除一個已有的環境
conda remove --name python36 --all
5、conda包管理
5.1安裝xxxx
conda install xxxx
5.2查看當前環境下已安裝的包
conda list
5.3查看某個指定環境的已安裝包
conda list -n python36
5.4查找package信息
conda search numpy
5.5安裝package
conda install -n python34 numpy # 如果不用-n指定環境名稱,則被安裝在當前活躍環境 也可以通過-c指定通過某個channel安裝
6、Conda 更新
6.1 更新package
conda update -n python34 numpy
6.2 刪除package
conda remove -n python34 numpy
6.3 更新conda,保持conda最新
conda update -n base conda
6.4 更新anaconda
conda update anaconda
6.5 更新python
conda update python
7、pip使用
# pip安裝包
$ pip install SomePackage
[...]
Successfully installed SomePackage
# pip查看已安裝的包
$ pip show --files SomePackage
Name: SomePackage
Version: 1.0
Location: /my/env/lib/pythonx.x/site-packages
Files:
../somepackage/__init__.py
[...]
# pip檢查哪些包需要更新
$ pip list --outdated
SomePackage (Current: 1.0 Latest: 2.0)
# pip升級包
$ pip install --upgrade SomePackage
[...]
Found existing installation: SomePackage 1.0
Uninstalling SomePackage:
Successfully uninstalled SomePackage
Running setup.py install for SomePackage
Successfully installed SomePackage
# pip卸載
$ pip uninstall SomePackage
Uninstalling SomePackage:
/my/env/lib/pythonx.x/site-packages/somepackage
Proceed (y/n)? y
Successfully uninstalled SomePackage