anaconda - juedaiyuer/researchNote GitHub Wiki
Anaconda使用笔记
安装
使用清华大学开源软件镜像站下载较快
bash你下载的文件名称,比如下面的命令
$ bash Anaconda3-4.3.1-Linux-x86_64.sh
对于Mac、Linux系统,Anaconda安装好后,实际上就是在主目录下多了个文件夹(~/anaconda)而已,Windows会写入注册表。
install later anaconda tell you information
You may wish to edit your .bashrc or prepend the Anaconda3 install location:
$ export PATH=/home/juedaiyuer/anaconda3/bin:$PATH
配置
sudo gedit ~/.bashrc
在文件末尾处添加
export PATH="/home/juedaiyuer/anaconda3/bin:$PATH"
$ source ~/.bashrc
检查是否配置成功
$ conda --version
conda 4.3.14
TUNA 还提供了 Anaconda 仓库的镜像,运行以下命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
$ python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
环境管理
使用conda env list查询
$ conda env list
# conda environments:
#
py2tf10 /home/juedaiyuer/anaconda3/envs/py2tf10
root * /home/juedaiyuer/anaconda3
或者使用conda info -e查询
$ conda info -e
# conda environments:
#
py2tf10 /home/juedaiyuer/anaconda3/envs/py2tf10
root * /home/juedaiyuer/anaconda3
创建新的环境
# 指定python版本为2.7,注意至少需要指定python版本或者要安装的包,未指定的情况下,自动安装最新python版本
# env_name文件可以在Anaconda安装目录envs文件下找到
conda create -n env_name python=2.7
# 同时安装必要的包
conda create -n env_name numpy matplotlib python=2.7
# 环境切换
# 切换到新环境
source activate env_name
# 退出环境,也可以使用`activate root`切回root环境
# linux
source deactivate env_name
# 移除环境
conda remove -n env_name --all
# 在你创建的环境下,安装额外的包
conda install -n env_name(环境名称) 扩展名(eg:scipy...)
# 删除环境中的某个包
conda remove --name env_name 删除的包名
使用例子
安装tensorflow
$ conda create -n py2tf10 python=2.7
env success install tell you as follow:
# To activate this environment, use:
# > source activate py2tf10
#
# To deactivate this environment, use:
# > source deactivate py2tf10
#
进入环境后,前面会有这样的标识(新环境的名称为前缀)
(py2tf10) juedaiyuer@juedaiyuer:~$
$ pip install --ignore-installed --upgrade TF_PYTHON_URL
安装tensorflow v1.0版本
$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl
python爬虫环境
$ conda create -n py2crawler python=2.7
conda的包管理
# 安装包,比如scikit-learn
conda install scikit-learn
# 安装制定版本
[package-name]=x.x
conda的repo中的扩展不算太新,如果想要更新的,可能要用PyPI或者自己下载源码。而conda和pip关联的很好。使用pip安装的东西可以使用conda来管理,这点要比Canopy好。
jupyter notebook
~/anaconda3/bin$ jupyter-notebook
或者
$ ipython notebook
conda list
看一下所有安装时自带的Python扩展