先去python官网:https://www.python.org/ 选择适合你电脑版本的python压缩包
其他的辅助工具去官网下载:https://pypi.org/
将下载好的压缩包拷贝到虚拟机上
在虚拟机终端做如下操作:
[root@python3 ~]# ls
python3_pkg
[root@python3 ~]# cd python3_pkg/
[root@python3 python3_pkg]# vim 1.sh
#!/bin/bash
yum install -y sqlite-devel tk-devel tcl-devel readline-devel zlib-devel gcc gcc-c++ openssl-devel libffi-devel
tar xzf Python-3.6.7.tgz
cd Python-3.6.7
./configure --prefix=/usr/local/
make && make install
[root@python3 python3_pkg]# ls
1.sh Python-3.6.7
[root@python3 python3_pkg]# cd Python-3.6.7/
[root@python3 Python-3.6.7]# ls
aclocal.m4 Include Modules Python
build install-sh Objects python-config
config.guess Lib Parser python-config.py
config.log libpython3.6m.a PC python-gdb.py
config.status LICENSE PCbuild README.rst
config.sub Mac Programs setup.py
configure Makefile pybuilddir.txt Tools
configure.ac Makefile.pre pyconfig.h
Doc Makefile.pre.in pyconfig.h.in
Grammar Misc python
[root@python3 Python-3.6.7]# python3
Python 3.6.7 (default, Feb 2 2020, 15:18:15)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@python3 Python-3.6.7]# python3 -m venv ~/nsd2020 #创建虚拟环境
[root@python3 Python-3.6.7]# ls ~/nsd2020
bin include lib lib64 pyvenv.cfg
[root@python3 Python-3.6.7]# source ~/nsd2020/bin/activate #激活虚拟环境
(nsd2020) [root@python3 Python-3.6.7]# python --version
Python 3.6.7
(nsd2020) [root@python3 Python-3.6.7]# which python
/root/nsd2020/bin/python