2021-05-21 18:49:55 索煒達(dá)電子 8109
conda是一種python環(huán)境管理程序,conda和anaconda一起能解決很多環(huán)境、包管理的問題。而且安裝anaconda的過程中會一并安裝scipy,numpy等很多常用的包,可以說是用python進(jìn)行科學(xué)計算和數(shù)據(jù)分析的必備神器,沒用過的同學(xué)還不快去體驗一下。本文總結(jié)了一下conda的常見命令
查詢完整幫助文件
conda create --help or conda create -h 其實(shí)“--”參數(shù)一般都有簡寫。
管理conda和anaconda
conda info 查詢conda信息
conda update conda 升級conda
conda update anaconda 升級anaconda
管理環(huán)境
conda info -e 環(huán)境信息
conda create -n test python=2.7 創(chuàng)建環(huán)境test,并指定python版本,此例為2.7
source activate test 激活環(huán)境
source deactivate test 關(guān)閉環(huán)境
conda remove --name test --all 刪除環(huán)境
包管理
conda list 列出所有安裝的包的信息
conda search beautiful-soup 查詢包
conda install -n test beautiful-soup 安裝包,并指定安裝環(huán)境,如果沒有-n test,則安裝到當(dāng)前環(huán)境
conda update beautiful-soup 升級包
conda remove -n test beautiful-soup 移除包
這就是最常用的conda命令
圖形界面——anaconda-navigator
當(dāng)然有人不喜歡用命令行,那我推薦你用anaconda-navigator,conda install anaconda-navigator 即可安裝,使用十分簡單,自己摸索即可,推薦新手使用!
-i https://mirror.baidu.com/pypi/simple
注意:conda 和 pip 之類包管理或者 virtualenv 之類虛擬環(huán)境管理軟件不要一同使用。用conda就只用conda,否則容易出錯,切記。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
conda activate
============
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
============
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple protobuf==3.19.0