Linux Anaconda use, offline installation package and its dependent libraries

1. Take offline installation of skimage package as an example

1.1 Download skimage package dependencies in batches

If you need to install scikit-image and its dependent libraries in an environment without network connection, a more useful method is:

On another network-connected computer, use the package manager pip or conda to download scikit-image and its dependencies. For example, use pip to download (conda has removed download), and open the terminal under the path to be downloaded :

pip download scikit-image

This will download scikit-image and all dependencies to the current directory.
insert image description here

1.2 Batch installation

Copy all downloaded files to a computer without internet connection. You can use a storage device such as USB for copying.

On an offline computer, use the package manager pip or conda to install. For example, use pip to install ( need to be installed under base ):

pip install --no-index --find-links=/path/to/downloaded/files/ scikit-image

where /path/to/downloaded/files/is the storage path of the downloaded file in the first step. This command tells pip to find the dependent library in the specified path and install it. Installation using conda is similar to:

conda install --offline /path/to/downloaded/files/scikit-image*.tar.bz2

Make sure the dependencies are installed correctly. You can run the following code in Python to check that all dependent libraries are installed correctly:

import numpy
import scipy
import matplotlib
import networkx
import pillow
import imageio
import tifffile
import pywt
import skimage

print("All dependencies are installed.")

If "All dependencies are installed." is output, it means that all dependencies are installed correctly.

Note that since scikit-image depends on many other libraries, its installation may be complicated. If you encounter problems during the installation process, please refer to the official documentation or community help.

2. Anaconda installation and use

2.1 Download and install

Anaconda installation is relatively simple, mirror download link (official website download is very slow):
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

2.2 use

2.2.1 View the installed Python version in Anaconda

command: conda list python
result:

(base) -virtual-machine:~$ conda list python
# packages in environment at /home//anaconda3:
#
# Name                    Version                   Build  Channel
ipython                   7.19.0           py38hb070fc8_0  
ipython_genutils          0.2.0                    py38_0  
msgpack-python            1.0.0            py38hfd86e86_1  
python                    3.8.5                h7579374_1  
python-dateutil           2.8.1                      py_0  
python-jsonrpc-server     0.4.0                      py_0  
python-language-server    0.35.1                     py_0  
python-libarchive-c       2.9                        py_0  

2.2.2 View the installed packages in the environment

Order:pip list -v

2.2.3 View the existing virtual environment in this environment

Order:conda info --envs

(base) -virtual-machine:~$ conda info --envs
# conda environments:
#
base                  *  /home/anaconda3

2.2.4 Create a virtual environment myenv and specify the python version

Command: conda create -n myenv python=3.8, you can use conda install or pip install in the myenv environment to install the required packages, activate the myenv environment conda activate myenv, and install the required packages in the myenv environment, for example, install

conda install numpy

or

pip install numpy

2.2.5 Open and close the virtual environment myenv

open: conda activate myenv
close:conda deactivate

2.2.5 Remove the virtual environment myenv

Order:conda remove --name myenv --all

2.2.6 Environment Replication

conda create -n 新环境名 --clone 旧环境名

3. Set up a new virtual environment in Pycharm

Suppose I have an environment called gdal_env, which can be used after the following settings, otherwise the base virtual environment is still used.
insert image description here

Refer to
ChatGPT www.openai.com

Guess you like

Origin blog.csdn.net/wokaowokaowokao12345/article/details/129178676