install tcl/tk module for Python3/2

本文详细介绍了在Ubuntu系统中为Python开发环境安装必要库及TCL/TK的过程。包括了使用apt-get安装libx11-dev等依赖库,以及从源代码编译安装TCL和TK的具体步骤。

 

1.prepare:

把下面这个常用库都安装:

    sudo apt-get install libx11-dev     

    sudo apt-get install autoconf curl libmysqld-dev libaio-dev libjpeg62-dev libpng12-dev libfreetype6-dev libssl-dev zlib1g-dev
    sudo apt-get install  libbz2-dev libgdbm-dev  
    sudo apt-get install sqlite3 libsqlite3-tcl libsqlite3-dev  
    sudo apt-get install  python-bsddb3  

 

python2:

sudo apt-get install python-tk  

python3:

sudo apt-get install python3-tk  

2.download and install native tcl和tk

tcl和tk的下载地址:http://www.tcl.tk/software/tcltk/download.html

目前我下载的tcl/tk源代码 from:

https://astuteinternet.dl.sourceforge.net/project/tcl/Tcl/8.7a3/tcl8.7a3-src.tar.gz

https://astuteinternet.dl.sourceforge.net/project/tcl/Tcl/8.7a3/tk8.7a3-src.tar.gz

(1) 安装tcl8.7a3-src.tar.gz

tar -xzvf tcl8.7a3-src.tar.gz  

cd tcl8.7a3/unix  

执行./configure脚本生成makefile文件

./configure  

编译

make

安装

sudo make install  

(2)安装tk8.7a3-src.tar.gz:

执行./configure脚本生成makefile文件

./configure

编译:

make

接着安装:

sudo make install  
 

stellaechen@STELLAECHEN-MC1 Python-2.7.13 % make ./python.exe -E -S -m sysconfig --generate-posix-vars ;\ if test $? -ne 0 ; then \ echo "generate-posix-vars failed" ; \ rm -f ./pybuilddir.txt ; \ exit 1 ; \ fi running build running build_ext building &#39;_Qt&#39; extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/stellaechen/download/Python-2.7.13/Mac/Include -I. -IInclude -I./Include -I/usr/local/include -I/Users/stellaechen/download/Python-2.7.13/Include -I/Users/stellaechen/download/Python-2.7.13 -c /Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.c -o build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.o -Wno-deprecated-declarations error: unable to open output file &#39;build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Mac/Modules/qt/_Qtmodule.o&#39;: &#39;Operation not permitted&#39; 1 error generated. building &#39;_tkinter&#39; extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tcl.framework/Versions/Current/PrivateHeaders -I/System/Library/Frameworks/Tk.framework/Headers -I/System/Library/Frameworks/Tk.framework/Versions/Current/PrivateHeaders -I/usr/X11R6/include -I/Users/stellaechen/download/Python-2.7.13/Mac/Include -I. -IInclude -I./Include -I/usr/local/include -I/Users/stellaechen/download/Python-2.7.13/Include -I/Users/stellaechen/download/Python-2.7.13 -c /Users/stellaechen/download/Python-2.7.13/Modules/_tkinter.c -o build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Modules/_tkinter.o -framework Tk clang: warning: -framework Tk: &#39;linker&#39; input unused [-Wunused-command-line-argument] In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_tkinter.c:71: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/tk.h:86:11: fatal error: &#39;X11/Xlib.h&#39; file not found 86 | # include <X11/Xlib.h> | ^~~~~~~~~~~~ 1 error generated. building &#39;_ctypes&#39; extension gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I_ctypes/darwin -I/Users/stellaechen/download/Python-2.7.13/Mac/Include -I/Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include -I/Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/powerpc -I. -IInclude -I./Include -I/usr/local/include -I/Users/stellaechen/download/Python-2.7.13/Include -I/Users/stellaechen/download/Python-2.7.13 -c /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c -o build/temp.macosx-15.4-arm64-2.7/Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.o -DMACOSX In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:65:3: error: "Unsupported MacOS X CPU type" 65 | # error "Unsupported MacOS X CPU type" | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:73: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffitarget.h:12:2: error: "Unsupported CPU type" 12 | #error "Unsupported CPU type" | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:74: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/fficonfig.h:51:2: error: "Unknown CPU type" 51 | #error "Unknown CPU type" | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:113: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:171:5: error: unknown type name &#39;ffi_abi&#39; 171 | ffi_abi abi; | ^ /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:193:2: error: unknown type name &#39;ffi_sarg&#39; 193 | ffi_sarg sint; | ^ /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:194:2: error: unknown type name &#39;ffi_arg&#39; 194 | ffi_arg uint; | ^ /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/libffi_osx/include/ffi.h:307:11: error: unknown type name &#39;ffi_abi&#39; 307 | ffi_abi abi, | ^ In file included from /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/_ctypes.c:129: /Users/stellaechen/download/Python-2.7.13/Modules/_ctypes/ctypes.h:99:5: error: unknown type name &#39;ffi_closure&#39; 99 | ffi_closure *pcl_write; /* the C callable, writeable */ | ^ 8 errors generated. Python build finished, but the necessary bits to build these modules were not found: _bsddb _curses _curses_panel _sqlite3 _ssl bsddb185 bz2 dbm dl gdbm imageop linuxaudiodev nis ossaudiodev readline spwd sunaudiodev zlib To find the necessary bits, look in setup.py in detect_modules() for the module&#39;s name. Failed to build these modules: _ctypes _Qt _tkinter running build_scripts stellaechen@STELLAECHEN-MC1 Python-2.7.13 % make install /usr/bin/install -c python.exe /usr/local/bin/python2.7 install: /usr/local/bin/INS@20xsco: Permission denied make: *** [altbininstall] Error 71 stellaechen@STELLAECHEN-MC1 Python-2.7.13 %
07-05
Traceback (most recent call last): File "d:\projects\samsung\visualize_hrir.py", line 145, in <module> plot_hrir_waveforms(sofa_path) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ File "d:\projects\samsung\visualize_hrir.py", line 48, in plot_hrir_waveforms fig, axes = plt.subplots(2, 2, figsize=(14, 10)) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\projects\.venv\Lib\site-packages\matplotlib\pyplot.py", line 1777, in subplots fig = figure(**fig_kw) File "D:\projects\.venv\Lib\site-packages\matplotlib\pyplot.py", line 1042, in figure manager = new_figure_manager( num, figsize=figsize, dpi=dpi, facecolor=facecolor, edgecolor=edgecolor, frameon=frameon, FigureClass=FigureClass, **kwargs) File "D:\projects\.venv\Lib\site-packages\matplotlib\pyplot.py", line 552, in new_figure_manager return _get_backend_mod().new_figure_manager(*args, **kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "D:\projects\.venv\Lib\site-packages\matplotlib\backend_bases.py", line 3504, in new_figure_manager return cls.new_figure_manager_given_figure(num, fig) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "D:\projects\.venv\Lib\site-packages\matplotlib\backend_bases.py", line 3509, in new_figure_manager_given_figure return cls.FigureCanvas.new_manager(figure, num) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ File "D:\projects\.venv\Lib\site-packages\matplotlib\backend_bases.py", line 1785, in new_manager return cls.manager_class.create_with_canvas(cls, figure, num) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "D:\projects\.venv\Lib\site-packages\matplotlib\backends\_backend_tk.py", line 535, in create_with_canvas window = tk.Tk(className="matplotlib") File "D:\software\python\Lib\tkinter\__init__.py", line 2465, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _tkinter.TclError: Can&#39;t find a usable tk.tcl in the following directories: D:/software/python/tcl/tcl8.6/tk8.6 D:/software/python/tcl/tk8.6 D:/software/lib/tk8.6 D:/software/lib/tk8.6 D:/lib/tk8.6 D:/software/library D:/software/python/tcl/tk8.6/tk.tcl: invalid command name "<##" invalid command name "<##" while executing "<## NASCA DRM FILE - VER1.00 ##>l " (file "D:/software/python/tcl/tk8.6/msgs/zh_cn.msg" line 1) invoked from within "::source -encoding utf-8 D:/software/python/tcl/tk8.6/msgs/zh_cn.msg" (in namespace inscope "::tk::msgcat" script line 1) invoked from within "namespace inscope $ns [list ::source -encoding utf-8 $langfile]" (procedure "Load" line 34) invoked from within "Load $ns [PackageLocales $ns]" (procedure "::msgcat::mcpackageconfig" line 46) invoked from within "::msgcat::mcpackageconfig set mcfolder D:/software/python/tcl/tk8.6/msgs" ("uplevel" body line 1) invoked from within "uplevel 1 [list [namespace origin mcpackageconfig] set mcfolder $langdir]" (procedure "::msgcat::mcload" line 2) invoked from within "::msgcat::mcload [file join $::tk_library msgs]" (in namespace eval "::tk::msgcat" script line 23) invoked from within "namespace eval msgcat { namespace export mc mcmax if {[interp issafe] || [catch {package require msgcat}]} { # The msgcat package..." (in namespace eval "::tk" script line 3) invoked from within "namespace eval ::tk { # Set up the msgcat commands namespace eval msgcat { namespace export mc mcmax if {[interp issafe] || [catch {p..." (file "D:/software/python/tcl/tk8.6/tk.tcl" line 17) invoked from within "source -encoding utf-8 D:/software/python/tcl/tk8.6/tk.tcl" ("uplevel" body line 1) invoked from within "uplevel #0 [list source -encoding utf-8 $file]" This probably means that tk wasn&#39;t installed properly.这是什么报错
11-12
下载方式:https://pan.quark.cn/s/a4b39357ea24 布线问题(分支限界算法)是计算机科学和电子工程领域中一个广为人知的议题,它主要探讨如何在印刷电路板上定位两个节点间最短的连接路径。 在这一议题中,电路板被构建为一个包含 n×m 个方格的矩阵,每个方格能够被界定为可通行或不可通行,其核心任务是定位从初始点到最终点的最短路径。 分支限界算法是处理布线问题的一种常用策略。 该算法与回溯法有相似之处,但存在差异,分支限界法仅需获取满足约束条件的一个最优路径,并按照广度优先或最小成本优先的原则来探索解空间树。 树 T 被构建为子集树或排列树,在探索过程中,每个节点仅被赋予一次成为扩展节点的机会,且会一次性生成其全部子节点。 针对布线问题的解决,队列式分支限界法可以被采用。 从起始位置 a 出发,将其设定为首个扩展节点,并将与该扩展节点相邻且可通行的方格加入至活跃节点队列中,将这些方格标记为 1,即从起始方格 a 到这些方格的距离为 1。 随后,从活跃节点队列中提取队首节点作为下一个扩展节点,并将与当前扩展节点相邻且未标记的方格标记为 2,随后将这些方格存入活跃节点队列。 这一过程将持续进行,直至算法探测到目标方格 b 或活跃节点队列为空。 在实现上述算法时,必须定义一个类 Position 来表征电路板上方格的位置,其成员 row 和 col 分别指示方格所在的行和列。 在方格位置上,布线能够沿右、下、左、上四个方向展开。 这四个方向的移动分别被记为 0、1、23。 下述表格中,offset[i].row 和 offset[i].col(i=0,1,2,3)分别提供了沿这四个方向前进 1 步相对于当前方格的相对位移。 在 Java 编程语言中,可以使用二维数组...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值