天天看點

anaconda linux環境變量,配置anaconda環境(linux)

安裝Anaconda

1.下載下傳

wget https://repo.anaconda.com/archive/Anaconda3-5.0.1-Linux-x86_64.sh

安裝

在安裝包路徑下執行:

bash Anaconda3-5.0.1-Linux-x86_64.sh

安裝過程中會需要不斷回車來閱讀并同意license。

安裝路徑預設為使用者目錄(可以自己指定),最後需要确認将路徑加入使用者的.bashrc中。

編輯.bashrc檔案

打開檔案

vi ~/.bashrc # 編輯 .bashrc

在最後一行加入:

export PATH="$PATH:~/anaconda3/bin"

儲存

最後,立即使路徑生效,需要在使用者目錄下執行:(一定不要忘了執行)

source ~/.bashrc

檢視conda環境清單

conda info --envs

安裝 Astropy 和 IRAF

步驟

換源

conda添加源

# 附更換清華鏡像源的方式:

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda config --set show_channel_urls yes

# 附加庫:

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

conda config --add channels http://ssb.stsci.edu/astroconda

檢視源

conda config --show

删除源

conda config --remove channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

conda config --remove-key channels # 删除所有源

安裝

conda create -n iraf27 python=2.7 iraf-all pyraf-all stsci

啟動

~$ source activate iraf27

(iraf27) ~$ mkdir iraf

(iraf27) ~$ cd iraf

(iraf27) iraf$ mkiraf

-- creating a new uparm directory

Terminal types: xgterm,xterm,gterm,vt640,vt100,etc.

Enter terminal type [default xterm-256color]: xgterm

A new LOGIN.CL file has been created in the current directory.

You may wish to review and edit this file to change the defaults.

You may also add additional customizations to loginuser.cl

編輯login.cl

# LOGIN.CL -- User login file for the IRAF command language.

# Identify login.cl version (checked in images.cl).

if (defpar ("logver"))

logver = "IRAF V2.16 March 2012"

set home = "/home/zy/iraf/"

set imdir = "./" # edit!!

set cache = "U_CACHEDIR"

set uparm = "home$uparm/"

set userid = "zy"

# Set the terminal type. We assume the user has defined this correctly

# when issuing the MKIRAF and no longer key off the unix TERM to set a

# default.

if (access (".hushiraf") == no)

print "setting terminal type to xgterm..."

stty xgterm

# Uncomment and edit to change the defaults.

set editor = vi # edit!! 設定編輯器

#set printer = lp

#set pspage = "letter"

#set stdimage = imt800

#set stdimcur = stdimage

#set stdplot = lw

#set clobber = no

#set imclobber = no

#set filewait = yes

#set cmbuflen = 512000

#set min_lenuserarea = 64000

set imtype = "fits" # edit!! 設定圖像格式

set imextn = "oif:imh fxf:fits,fit fxb:fxb plf:pl qpf:qp stf:hhh,??h"

# XIMTOOL/DISPLAY stuff. Set node to the name of your workstation to

# enable remote image display. The trailing "!" is required.

#set node = "my_workstation!"

# CL parameters you mighth want to change.

#ehinit = "nostandout eol noverify"

#epinit = "standout showall"

showtype = yes

# Default USER package; extend or modify as you wish. Note that this can

# be used to call FORTRAN programs from IRAF.

package user

task $adb $bc $cal $cat $comm $cp $csh $date $dbx $df $diff = "$foreign"

task $du $find $finger $ftp $grep $lpq $lprm $ls $mail $make = "$foreign"

task $man $mon $mv $nm $od $ps $rcp $rlogin $rsh $ruptime = "$foreign"

task $rwho $sh $spell $sps $strings $su $telnet $tip $top = "$foreign"

task $awk $vi $emacs $w $wc $less $rusers $sync $pwd $gdb = "$foreign"

task $more = "$foreign"

# edit!!

task $xc $mkpkg $generic $rtar $wtar $buglog = "$foreign"

#task $fc = "$xc -h $* -limfort -lsys -lvops -los"

task $fc = ("$" // envget("iraf") // "unix/hlib/fc.csh" //

" -h $* -limfort -lsys -lvops -los")

task $nbugs = ("$(setenv EDITOR 'buglog -e';" //

"less -Cqm +G " // envget ("iraf") // "local/bugs.*)")

task $cls = "$clear;ls"

task $clw = "$clear;w"

task $pg = ("$(less -Cqm $*)")

if (access ("home$loginuser.cl"))

cl < "home$loginuser.cl"

;

keep

# Load the default CL package. Doing so here allows us to override package

# paths and load personalized packages from our loginuser.cl.

clpackage

# List any packages you want loaded at login time, ONE PER LINE.

images # general image operators

plot # graphics tasks

dataio # data conversions, import export

lists # list processing

# The if(deftask...) is needed for V2.9 compatibility.

if (deftask ("proto"))

proto # prototype or ad hoc tasks

tv # image display

utilities # miscellaneous utilities

noao # optical astronomy packages

vo # Virtual Observatory tools

plot

prcache directory

cache directory page type help

# Print the message of the day.

if (access (".hushiraf"))

menus = no

else {

type hlib$motd

}

# Uncomment to initialize the SAMP interface on startup.

if (deftask ("samp") == yes) {

printf ("Initializing SAMP .... ")

if (sampHubAccess() == yes) {

# Enable SAMP messaaging. Set default handlers that don't require

# VO capabilities.

samp quiet

samp ("on", >& "dev$null")

# samp ("handler", "table.load.votable", "tinfo $url", >& "dev$null")

# samp ("handler", "image.load.fits", "imstat $url", >& "dev$null")

samp noquiet

print ("on")

} else

print ("No Hub Available\n")

}

# Delete any old MTIO lock (magtape position) files.

if (deftask ("mtclean"))

mtclean

else

delete uparm$mt?.lok,uparm$*.wcs verify-

keep

設定環境變量

Cl>set terminal=vt100

一些報錯的解決方式

1.conda install 時出錯: CondaError: Downloaded bytes did not match Content-Length

方法一

換源

方法二

設定conda下載下傳的timeout,然後再進行嘗試,如果時長不夠可以再設定大一點。

conda config --set remote_read_timeout_secs 600.0

然後運作安裝指令

conda install 包 即可。

方法三

從conda的源下載下傳好要安裝的包,直接采用本地安裝的方式。下載下傳的url再出錯的地方有提示:

url: http://ssb.stsci.edu/astroconda/linux-64/iraf-2.16.UR.1-0.tar.bz2

離線安裝:

conda install --offline ./iraf-2.16.UR.1-0.tar.bz2

啟動iraf時輸入cl報錯:/usr/local/bin/rar: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

原因:64位系統中安裝了32位程式

解決方法:

yum install glibc.i686

重新安裝以後還有如下類系錯誤 再繼續安裝包

error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

yum install libstdc++.so.6

conda安裝ds9

conda install -c pkgw/label/superseded ds9

jupyter notebook配置

修改jupyter_notebook_config.py

jupyter notebook --generate-config

vi /home/zy/.jupyter/jupyter_notebook_config.py

作如下修改:

c.NotebookApp.allow_root = Ture

c.NotebookApp.notebook_dir = '路徑'

關聯Jupyter Notebook和conda的環境和包——“nb_conda”

conda install nb_conda