anaconda3安裝及虛擬環境管理、pip

安裝anaconda3參考:

https://blog.csdn.net/qq_15192373/article/details/81091098

安裝完成後需重啓終端,或者輸入source ~/.bashrc

再輸入python就會進入anaconda的python版本

 

anaconda使用,包管理:

https://blog.csdn.net/atpuxiner/article/details/85473485

創建虛擬環境

# 查看命令幫助
conda create --help
# 創建虛擬環境,指定名稱和python版本
conda create --name venv-name python=3.6

conda create -n venv-name python=3.6.5

#列出conda已創建的環境

conda env list

# 刪除一個已有的環境

conda remove --name venv-name --all

 

conda添加清華源:

1、使用如下命令

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

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

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

從channel中安裝包時顯示channel的url,可以進行一下設置:

conda config --set show_channel_urls yes

若不想顯示,可設置爲no

參考:

https://www.jianshu.com/p/21f35cb966fc

2、在home目錄下.condarc文件中粘貼地址,這樣就很全了

但剛開始home目錄下沒有.condarc文件,使用sudo gedit ~/.condarc會創建文件,1中命令也會生成這個文件

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

清華源官網Anaconda 鏡像使用幫助

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

 

 

使用yaml文件安裝指定環境

參見anaconda官網環境管理https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file

# 執行如下命令可以將當前環境下的 package 信息存入名爲 environment 的 YAML 文件中。
conda env export > environment.yaml

# 同樣,當執行他人的代碼時,也需要配置相應的環境。這時你可以用對方分享的 YAML 文件來創建一摸一樣的運行環境。

conda env create -f environment.yaml

安裝時報錯:prefix already exists: /home/jason/anaconda3

原因是yaml文件的首行爲新安裝的環境名,與已有的環境名重複,改掉。但是還是報了別的錯,有個網址沒識別

原因是這個網址需要翻牆,把yaml中進不去的網址刪掉,留下鏡像源就可以了,帶jd的都刪掉

使用該命令創建環境時pip安裝的包會裝到系統的Python目錄下

#顯示包安裝的位置

pip show “包名”  ,例如pip show absl-py。如果安在了conda某個虛擬環境下,則在該環境下才顯示

如果想安裝在conda環境下面,把pip後面的包去掉,在conda環境下安裝pip/pip3後再用該pip/pip3安裝

#查看當前的pip所在目錄:

which pip

#在conda虛擬環境下安裝pip/pip3。pip可能把庫安裝到python2裏,沒有python2則兩者一樣,pip3安裝起來比較麻煩?

#conda安裝pip:

conda install pip

#anaconda安裝pip3

https://blog.csdn.net/u013241595/article/details/101160741

#使用如下命令安裝pip庫

pip install -r cuda100_pip.txt

cuda100_pip.txt文件格式如下:

不知道在.yaml文件中加入pip的安裝,然後再安裝會不會可以????

 

#keras-contrib庫安裝不上,各種源裏面都沒有,找到git源碼下載安裝(百度查不到安裝方法,在必應上搜keras-contrib install)

https://interviewbubble.com/importerror-no-module-named-keras_contrib/

pip install git+https://www.github.com/keras-team/keras-contrib.git


 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章