0. 准备操作系统及安装包
- 准备操作系统环境:
首先安装依赖包,安装相应的编译工具
bash
[root@bigdatahost bin]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
2。 解压离线包:
bash
[root@DeepLearning intasllpython]# tar -xvf LinuxPython.tar
1. 离线安装python3.8
- 在/usr/local下创建python3.8目录
bash
[root@DeepLearning local]# cd /usr/local
[root@DeepLearning local]# mkdir python3.8
- 拷贝文件Python-3.8.16.tgz到新建临时安装目/home/python/intasllpython,解压文件:
bash
[root@DeepLearning intasllpython]# tar xzvf Python-3.8.16.tgz
- 指定安装目录,解压后,进入Python-3.8.16目录,指定安装目标:
bash
[root@DeepLearning local]# cd /home/python/intasllpython/Python-3.8.16
[root@DeepLearningPython-3.8.16]# ./configure --prefix=/usr/local/python3.8
- 编译
bash
[root@DeepLearningPython-3.8.16]# make
- 安装:
bash
[root@DeepLearningPython-3.8.16]# make install
最后,提示:
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-22.0.4 setuptools-56.0.0
- 检查验证,进入目录:/usr/local/python3.8/bin,运行:
bash
[root@DeepLearning bin]# ./python3 -V
Python 3.8.16
[root@DeepLearning bin]# ./pip3.8 list
Package Version
---------- -------
pip 22.0.4
setuptools 56.0.0
- 创建软链接
bash
[root@bigdatahost bin]# ln -s /usr/local/python3.8/bin/python3 /usr/bin/python3
[root@bigdatahost bin]# ln -s /usr/local/python3.8/bin/pip3 /usr/bin/pip3
2. 安装whl格式文件
在Linux上按文件列表名称安装.whl包,其中文件列表放在文本文件中,可以按照以下步骤进行。假设文件列表保存为requirements.txt,并且所有.whl文件都位于当前目录:
bash
[root@DeepLearning Linux]# xargs -a requirements.txt -I {} /usr/local/python3.8/bin/pip3.8 install {}
相当于:
pip3 install 文件名
安装需要按照如下列表文件的顺序进行(包有依赖关系,否则安装不上,需要手动处理):
numpy-1.22.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
scipy-1.7.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
tifffile-2023.7.10-py3-none-any.whl
PyWavelets-1.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pillow-10.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
packaging-24.1-py3-none-any.whl
networkx-3.1-py3-none-any.whl
imageio-2.9.0-py3-none-any.whl
scikit_image-0.19.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pytz-2024.1-py2.py3-none-any.whl
tzdata-2024.1-py2.py3-none-any.whl
six-1.16.0-py2.py3-none-any.whl
idna-3.7-py3-none-any.whl
urllib3-1.26.9-py2.py3-none-any.whl
charset_normalizer-3.3.2-py3-none-any.whl
python_dateutil-2.9.0.post0-py2.py3-none-any.whl
h5py-3.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
zipp-3.19.2-py3-none-any.whl
pandas-1.4.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
tqdm-4.66.4-py3-none-any.whl
stanio-0.5.0-py3-none-any.whl
pyparsing-3.1.2-py3-none-any.whl
kiwisolver-1.4.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
fonttools-4.53.1-py3-none-any.whl
cycler-0.12.1-py3-none-any.whl
contourpy-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
certifi-2024.7.4-py3-none-any.whl
requests-2.32.3-py3-none-any.whl
importlib_resources-6.4.0-py3-none-any.whl
holidays-0.52-py3-none-any.whl
matplotlib-3.7.5-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
cmdstanpy-1.2.4-py3-none-any.whl
typing_extensions-4.12.2-py3-none-any.whl
greenlet-3.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
PyMySQL-1.1.1-py3-none-any.whl
SQLAlchemy-2.0.31-py3-none-any.whl
joblib-1.4.2-py3-none-any.whl
threadpoolctl-3.5.0-py3-none-any.whl
scikit_learn-1.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl
tzlocal-5.2-py3-none-any.whl
APScheduler-3.10.4-py3-none-any.whl
pika-1.3.2-py3-none-any.whl
MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
itsdangerous-2.2.0-py3-none-any.whl
importlib_metadata-8.0.0-py3-none-any.whl
click-8.1.7-py3-none-any.whl
blinker-1.8.2-py3-none-any.whl
werkzeug-3.0.3-py3-none-any.whl
jinja2-3.1.4-py3-none-any.whl
flask-3.0.3-py3-none-any.whl
loguru-0.7.2-py3-none-any.whl
pvlib-0.9.5-py3-none-any.whl
3. 安装tar形式的文件
bash
[root@DeepLearning Linux]# /usr/local/python3.8/bin/pip3.8 install bayesian-optimization-1.2.0.tar.gz
相当于:
- 解压tar包
bash
tar -xvf bayesian-optimization-1.2.0.tar.gz
- 进入解压后的目录,使用
cd
命令进入解压后的目录:
bash
cd bayesian-optimization-1.2.0
-
查看README或INSTALL文件
在解压后的目录中查找是否有
README
或INSTALL
文件,这些文件通常包含有关如何安装软件的说明和说明[。 -
安装依赖项
某些软件可能需要先安装一些依赖项。根据
README
或INSTALL
文件中的说明,使用包管理器(如apt、yum等)安装所需的依赖项。例如,在Debian/Ubuntu系统中,可以使用以下命令安装依赖:
bash
sudo apt-get install -y build-essential python3-dev
- 使用
pip3
安装包
如果软件提供了setup.py
文件,可以使用pip3
来安装该包:
bash
pip3 install .
注意,这里的点号表示当前目录。如果需要管理员权限,可以在前面加上
sudo
。
- 验证安装
安装完成后,可以通过输入软件名来验证安装是否成功:
bash
software --version
将
software
替换为实际的软件名称。
本文使用的离线包:CentOS环境上Python3.8及相关科学计算离线安装包。