Anaconda installation and use

Posted by hiasl on Tue, 08 Feb 2022 22:58:35 +0100

Anaconda installation

1.1 download installation files

1) If you want to download directly to the local server and upload to the remote server through ftp, please ignore the following operations

2) If the server is networked, you can directly download the server through wget command [centos version], as follows:

The linux system I use is centos7 6.18-64bits, the script file is downloaded using wget command, and the command is as follows:

wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
1.2 perform installation
Command: sh Anaconda3-2019.10-Linux-x86_64.sh

Press enter all the way, yes. If you don't want to install Anaconda in the / root/anaconda3 directory by default, you can enter the custom installation directory at this step

2. The configuration conda command can be used globally

When the anaconda environment is just installed, the conda command cannot be used and needs to be configured globally. The configuration method is as follows:

vi or vim command edit ~ / bashrc file,
Command: VIM ~ / bashrc
Add the following at the end of the document:

export PATH='anaconda Installation directory of/bin:$PATH'
  1. "ESC" exits the editing mode, ":" enters the command mode and enters wq! Save and exit;

  2. To make the modification effective, execute the command: source ~ / bashrc

  3. At this point, you can use the conda command in any path

  4. The conda update uses the following command:

conda update -n base conda
Query all current virtual environments
conda env list
Create virtual environment
conda create -n env_name python=X.X(python (version number)
Activate / switch virtual environment
conda activate env_name
Exit the current virtual environment
conda deactivate
Delete virtual environment
conda remove -n env_name --all
Install python package files in the current virtual environment
conda install package-name1

You can also use:

pip install package-name
Uninstall the python package file in the current virtual environment
conda remove package-name

You can also use:

pip uninstall package-name1
Shared virtual environment [package all python dependency packages and version information in the virtual environment into the environment configuration file]
conda env export > xxxx.yaml
Import someone else's virtual environment profile to the current virtual environment
conda env update -f=xxxx/xxxx/xxxx.yaml[Directory where the virtual environment configuration file is located]

conda

Enter conda base environment

conda activate base

Exit conda base environment

conda deactivate

Edit conda environment variable

vim ~/.bashrc

cuda version

nvcc --version

There is a problem with Ubuntu environment variables

root@ubuntu:~# vimCommand 'vim' is available in '/usr/bin/vim'The command could not be located because '/usr/bin' is not included in the PATH environment variable.vim: command not found

terms of settlement

Command line input

export PATH=/usr/bin:/bin

Change domestic image source

pip install -i https://pypi.douban.com/simple/ requests

Installation package

pip3 install -r requirements.txt

Anaconda use

-Anaconda Navigator: a graphical interface for managing toolkits and environments.
-Anaconda Prompt: command line interface for managing packages and environments.
-Jupyter Noterbook: a Web-based interactive computing environment used to demonstrate the process of data analysis and generate easy to read documents.
-Spyder: Python integrated development environment with layout similar to Matlab.

to configure

Open Anaconda Prompt

View software version number

python --version #see Python Version, here is Python3conda --version #View of conda

Add mirror

conda server is used very slowly abroad, so it needs to join the image of Tsinghua University in China.

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

Update conda

conda upgrade --all

Configure the compilation environment of Python 2 (if Python 2 is installed by default, you need to configure Python 3 here)

conda create -n python2 python=2.7

View the current compilation environment

conda info --e

With * is the default Python environment of root. Here I install Anaconda version that supports Python 3. The default here is Python 3

Switch compilation environment

activate python2 #switch Python Compile environment to Python2deactivate python2 #Exit environment conda remove -n python2 --all #Delete environment

View installed packages

conda listconda install scipy #install scipy,Installed in default Python In the environment conda install -n python2 numpy #Install numpy package in Python 2 compilation environment

Topics: Python Linux CentOS vim Algorithm