anaconda配置python35_如何正确使用Anaconda配置Python,R环境

本文详细介绍如何在Linux环境下安装并配置Anaconda科学计算平台,包括设置Python 2及Python 3环境,创建R环境,并解决过程中可能遇到的问题,如tcl包缺失等。
部署运行你感兴趣的模型镜像

这篇文章摘于我写在github上的一篇文章,希望大家多提意见,谢谢。

How to set up your own anaconda in a scientific way?

python2, python3, R in conda

Introduction

what is anaconda?

According to its own website, Anaconda is the leading open data science platform powered by Python. The open source version of Anaconda is a high performance distribution of Python and R and includes over 100 of the most popular Python, R and Scala packages for data science.

Or you can simply regard it as a manager of the packages of your programming languages.

why we want to use anaconda?

Convinient to manage packages

Jupyter notebook

object

Set up anaconda for a python and r user (linux)

I use py2 more often so I set it my default environment

Get started!

Click this link and download corresponding version of anaconda.

Type the following line in the terminal and the installation will be set up automatically

```bash Anaconda2-4.3.1-Linux-x86_64.sh``` .

Do include the "bash" command even if you are not using the bash shell.

Add the following line to the .bashrc or .zshrc(if you are a zsh user).

```export PATH="/home/zijun/anaconda2/bin:$PATH"```

Create python3 environment in your conda.

```conda create -n py3 python=3.5 anaconda```

Create R environment in your conda.

```conda create -n r -c r r-essentials```

Install tck for R (enable install.packages() in R)

```source activate r

conda install -c intel tcl=8.6.4```

Note1: if you want to remove environment you install:

```conda remove --name py3 --all```

Note2: switch different environment

```source activate r

source deactivate r```

Some issues you may encounter during the process

Q: tcl not found

install.packages('highfrequency')

--- Please select a CRAN mirror for use in this session ---

Error: .onLoad failed in loadNamespace() for 'tcltk', details:

call: fun(libname, pkgname)

error: Can't find a usable init.tcl in the following directories:

/opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library ./tcl8.5.18/library

A: Solution:

Just do the step 5 above to solve this problem.

Or add the following lines to the .bashrc or .zshrc

``` export TCL_LIBRARY="/home/zijun/anaconda2/lib/tcl8.5"

export TK_LIBRARY="/home/zijun/anaconda2/lib/tk8.5" ```

Note1: tck is a package which supports install.packages() function and it is installed in the global environment if you use sudo apt-get install tcl8.5-dev tk8.5-dev and conda has no access to it.

Note2: packages will be installed in /home/zijun/anaconda/envs/r/lib/R/library using install.packages()

Q: How to install packages in R

A: Since we set up the tcl, we can easily use install.packages() or remove.packages() to manage the R packages. However in this way, conda will lose control over r packages. Also you may find some suggestions using conda-build like this:

switch back to the root environment

type conda install conda-build in the terminal

Use conda skeleton cran and conda build to install packages (you may mind the dependency issue)

However this will not give you the control either. Moreover, there might be more issues about shitty sytax in R. So my suggestion is simply using install.packages() in R to install your packages.

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值