DownloadAnaconda
Enter Ubuntu, create a new download path yourself, and enter the following command to start downloading
Note that if it is not x86_64, you need to go to the mirror to see the corresponding version ( https://mirrors.bfsu.edu.cn/anaconda/archive/?C=M&O=A
)
wget https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-2022.10-Linux-x86_64.sh --no-check-certificate
Install Anaconda
input the command
bash Anaconda3-2021.11-Linux-x86_64.sh
Check the license after pressing Enter, press q to exit the license, and then enter yes to agree.
Confirm the installation path. Generally, press Enter to install in the default /home/your name/anaconda3
Installed quickly. Enter yes to confirm using conda init to start
Start environment variables
If you enter conda now, it will show that the command cannot be found
. You need to start the environment variable that has been modified. Enter the following command (you will not need to source it in the future, because it will automatically source when you start Ubuntu)
source ~/.bashrc
At this time, you will find that (base) appears.
If you look at ~/.bashrc, you can see that the path to conda has been added.
cat ~/.bashrc
Upgrade conda
If the current version installed is not the latest version, you can upgrade it with the following command
conda update -n base -c defaults conda
This upgrades from 4.10.3 to 4.11.0
current version: 4.10.3
latest version: 4.11.0
Create a virtual environment
Enter the following command to create a virtual environment named py39, the python version is 3.9
conda create -n py39 python=3.9
After entering y and pressing Enter, download and create
Enter virtual environment
Enter the following command to enter the virtual environment py39 we created
source activate py39
You can see that the prefix has changed from base to py39. After you enter python, you can see that the python version is 3.9.7
You can also add the following command line to ~/.bashrc, so that you only need to enter py39 to enter directly.
alias py39='source activate py39'
You can also add the following command to the last line of bashrc so that you will automatically enter py39 every time you log in to the server.
py39
Add python module
You can add the python module through the following command. First, you must install ipython.
conda install ipython
Then, for example, the commonly used pandas and xgboost
conda install pandas
conda install xgboost
Other conda commands
#创建虚拟环境
conda create -n your_env_name python=X.X(3.6、3.7等)
#激活虚拟环境
source activate your_env_name(虚拟环境名称)
#退出虚拟环境
source deactivate your_env_name(虚拟环境名称)
#删除虚拟环境
conda remove -n your_env_name(虚拟环境名称) --all
#查看安装了哪些包
conda list
#安装包
conda install package_name(包名)
conda install scrapy==1.3 # 安装指定版本的包
conda install -n 环境名 包名 # 在conda指定的某个环境中安装包
#查看当前存在哪些虚拟环境
conda env list
#或
conda info -e
#或
conda info --envs
#检查更新当前conda
conda update conda
#更新anaconda
conda update anaconda
#更新所有库
conda update --all
#更新python
conda update python