Python offline installation

Original link

In the absence of an external network, the Python environment can only be installed offline.

Install Python offline on Windows

Download address of Python offline installation package: https://www.python.org/ftp/python/

What I chose is:python-3.8.5-amd64.exe

Double-click to run the installation package to complete the installation.

After the installation is complete, add environment variables:

D:\Python3.8.5\
D:\Python3.8.5\Scripts\

Check whether it is successful:

python --version

Outputting the version number Python 3.8.5indicates successful installation.

If the output version number is incorrect, try changing the command python3 --version.

Install Python offline on Linux

Download address of Python offline installation package: https://www.python.org/ftp/python/

What I chose is:Python-3.8.5.tgz

Enter the decompression path:

cd /home/root/Download/Python-3.8.5

Set installation path:

./configure --prefix=/usr/local/python3 --enable-shared
make && make install

Establish a soft connection between python and pip:

ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3

Configure python3's lib to ldconfig:

echo "/usr/local/python3/lib" > /etc/ld.so.conf.d/python3.8.conf
ldconfig

Check whether Python is installed successfully:

python3 --version

Outputting the version number Python 3.8.5indicates successful installation.

Check whether pip is configured successfully:

pip3 --version

The following output indicates success:

pip 20.2.4 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)

Install Python on Ubuntu

The way Ubuntu installs Python is different from other Linux systems.

If there is a network connection, you can directly use the command line to install:

sudo apt-get install python3.8
sudo apt install python3-pip

If there is no Internet, you need to download the offline package first.

Download address of Python offline installation package: https://www.python.org/ftp/python/

What I chose is:Python-3.8.5.tgz

Unzip and enter the installation directory:

sudo tar -zxvf Python-3.8.5.tgz -C ~
cd Python-3.8.5

Install the compilation environment:

sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev  libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev   liblzma-dev libffi-dev  libc6-dev

If there is a network, sudo apt-getyou can use it directly. When offline, you need to download the above installation package and copy it in before installing it.

Initialize and specify path:

sudo ./configure --prefix=/usr/local/python3

Compile:

sudo make

test:

sudo make test

Install:

sudo make install

Add environment variables:

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

Create a soft link:

ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3

Check whether Python is installed successfully:

python3 --version

Outputting the version number Python 3.8.5indicates successful installation.

Install Anaconda offline for Windows

Download address of Anaconda offline installation package: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

The version I chose is: Anaconda3-2020.11-Windows-x86_64.exe;

For the version correspondence between Anaconda and Python, see: https://mp.weixin.qq.com/s/sDvdCviieYiEjKuDBLzRCQ

Double-click to run the installation package. in:

Install forchoose All Users;

Advanced OptionsUncheck Add Anaconda3 as the system PATH environment variable;

Other selections are default.

Add environment variables when finished:

D:\Anaconda
D:\Anaconda\Scripts 
D:\Anaconda\Library\bin
D:\Anaconda\Library\usr\bin 
D:\Anaconda\Library\mingw-w64\bin

Check whether Anaconda is installed successfully:

conda --version

Output the version number conda 4.9.2and the installation is successful.

Install Anaconda offline on Linux

Download address of Anaconda offline installation package: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

The version I chose is: Anaconda3-2020.11-Linux-x86_64.sh;

For the version correspondence between Anaconda and Python, see: https://mp.weixin.qq.com/s/sDvdCviieYiEjKuDBLzRCQ

Execute the following two commands in sequence:

chmod +x Anaconda3-2020.11-Linux-x86_64.sh
./Anaconda3-2020.11-Linux-x86_64.sh

Then a prompt will appear, just keep pressing Enter and press all the way;

During the subsequent installation process, you will be prompted: Please answer 'yes' or 'not', just enter them all yes;

Check whether Anaconda is installed successfully:

conda --version

Output the version number conda 4.9.2and the installation is successful.

Winodws offline installation of pip package

First create a new file requirements.txtand write the package that needs to be downloaded. For example:

transformers==4.27.1
torch>=1.10
pandas
numpy

Packages being downloaded requirements.txt:

pip3 download -d  D:\Download\package  -r requirements.txt

Download a single package (taking numpy as an example):

pip3 download -d  D:\Download\package numpy

Offline installation of downloaded packages:

pip3 install --no-index --find-links=D:\Download\package -r requirements.txt

Install a single package offline (taking numpy as an example):

pip3 install --no-index --find-links=D:\Download\package numpy

Linux offline installation pip package

First create a new file requirements.txtand write the package that needs to be downloaded. For example:

transformers==4.27.1
torch>=1.10
pandas
numpy

Packages being downloaded requirements.txt:

pip3 download -d  /usr/Download/package  -r requirements.txt

Download a single package (taking numpy as an example):

pip3 download -d  /usr/Download/package numpy

Offline installation of downloaded packages:

pip3 install --no-index --find-links=/usr/Download/package -r requirements.txt

Install a single package offline (taking numpy as an example):

pip3 install --no-index --find-links=/usr/Download/package numpy

 
 

To learn more programming knowledge, please follow my official account:

code path

 
 

Guess you like

Origin blog.csdn.net/zbzcDZF/article/details/131188748