赞
踩
Python Source Releases | Python.org
下载最新的Python源码
将源码拷贝到Linux环境上~/下
cd /home/autotest/tool/py
mkdir install
tar xzvf ~/Python-3.11.4.tgz -C /home/autotest/tool/py
cd Python-3.11.4
./configure --prefix=/home/autotest/tool/py/install
make
make 报错
/home/software/python/Modules/_ctypes/_ctypes.c:118:17: fatal error: ffi.h
解决方法:yum install libffi-devel
The necessary bits to build these optional modules were not found:
_bz2 _dbm _gdbm
_lzma _tkinter nis
readline
解决方法:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel xz-devel gdbm-devel
make install
这样在/home/autotest/tool/py/install 目录下就生成了许多文件,包括bin 和 lib等。
[root@localhost install]# ls
bin include lib share
[root@localhost install]#
[root@localhost bin]# ll python3
lrwxrwxrwx. 1 root root 9 Jun 24 18:07 python3 -> python3.11
[root@localhost bin]#
将bin目录加入PATH路径下。
export PATH=$PATH:/home/autotest/tool/py/install/bin
创建一个软连接 python 指向 python3
ln -s /home/autotest/tool/py/install/bin/python3.11 /usr/bin/python
[root@localhost bin]# python --version
Python 3.11.4
[root@localhost bin]#
[root@localhost bin]# pip3.11 --version
[root@localhost bin]# pip3 --version
[root@localhost bin]# cp /home/autotest/tool/py/install/bin/pip3 /usr/local/bin/
[root@localhost bin]# pip3 --version
pip3 install -U pip setuptools
pip3 install tomli
pip3 install flake8
pip3 install yapf
pip3 install pyserial
pip3 install paramiko
pip3 install xlrd
pip3 install xlwt
pip3 install xlutils
这样pip3 install的库将会存放到 install/lib/python3.11/site-packages
安装pcicrawler
[root@localhost py]# pip3 install pcicrawler
安装完后在 install/bin里面就会生成一个 pcicrawler 命令。
在将打包好的Python库放到另外一台Linux环境上时,报错
python: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/libpython2.7.so.1.0)
原因:这台Linux系统服务器是centos7.6的,我们的Python需要在centos8.2以上的运行
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。