1. 背景
Linux Python例子作成时需要Python环境,需要手动安装。
2. 所需材料
Python Linux Edition :Python-3.8.3.tgz
安装OS:(文档作成时的安装OS)
Ubuntu 20.04 LTS (kernel 5.4.0-26-generic)(64bit US)
Ubuntu 18.04.3 LTS (kernel 5.0.0-23-generic)(64bit US)
3. 安装步骤
- 安装所需lib
sudo apt-get update
sudo apt-get install zlib1g-dev
sudo apt-get install libffi-dev
- 安装Python-3.8.3
tar -xvf Python-3.8.3.tgz
cd Python-3.8.3
./configure
make
make test
sudo make install
- 运行例子以inout为例
python3 inout
4. 缺少库文件时报的错误
- 缺少zlib1g-dev
在make test时有以下错误
== Tests result: FAILURE then FAILURE ==
392 tests OK.
2 tests failed:
test_importlib test_normalization
29 tests skipped:
test_bz2 test_ctypes test_curses test_dbm_gnu test_dbm_ndbm
test_devpoll test_gzip test_idle test_ioctl test_kqueue test_lzma
test_msilib test_ossaudiodev test_readline test_smtpnet
test_sqlite test_ssl test_startfile test_tcl test_tix test_tk
test_ttk_guionly test_ttk_textonly test_turtle test_winconsoleio
test_winreg test_winsound test_zipfile64 test_zlib
2 re-run tests:
test_importlib test_normalization
Total duration: 4 min 35 sec
Tests result: FAILURE then FAILURE
make: *** [Makefile:1130: test] Error 2
- 缺少libffi-dev
执行例子时报错:
Traceback (most recent call last):
File "inout.py", line 3, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
备注:如果先安装了Python-3.8.3再安装lib需要重新安装Python-3.8.3