要求:
We want to build python v3.6.4 from source and then distribute it as tar so that it can be used in different machine by just untarring it. The built python needs to work with tcl v8.6
问题:
Built python is looking for tcl8.5
构建机器:CentOS 7
建设步骤如下:
- yum -y install openssl-devel wget gcc make tk-devel
- wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
- mkdir -p /opt/mayur/python/3.6.4/lib
- tar -xvf Python-3.6.4.tgz
- cd Python-3.6.4
- ./configure --prefix=/opt/mayur/python/3.6.4 --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /opt/mayur/python/3.6.4/lib"
- make altinstall
- tar cvf python3.6.4.tar -C /opt/mayur/python/3.6.4/
接下来当我在不同的机器上将上面构建的tar解压缩到/opt/mayur/python/3.6.4并运行import tkinter
时,它会抛出以下错误 -
File "/opt/mayur/python/3.6.4/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.5.so: cannot open shared object file: No such file or directory
通过一些调试,我能够理解centos仅支持tk-devel 8.5。所以在第一步中安装的tk-devel的版本是v8.5.13,因此,python正在寻找libtk8.5.so。
我看到了这篇文章post,并将我的配置更改为
./configure --prefix=/opt/mayur/python/3.6.4 --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /opt/mayur/python/3.6.4/lib" --with-tcltk-includes=-I/opt/mayur/tcl/8.6.6.8606/include --with-tcltk-libs=-L/opt/mayur/tcl/8.6.6.8606/lib
但这也不起作用。
有人可以提供一些关于如何构建python v3.6.4并将其链接到tcl8.6的指示吗? python如何决定使用哪个tcl?