我想从源代码构建Python 3.5.2。为此,我需要tcl和tk。我的配置:
./configure
--prefix=/home/****e/python/python35 \
--with-tcltk-includes="-I/opt/software/tcltk8.6/include" \
--with-tcltk-libs="-L/opt/software/tcltk8.6/lib -ltcl8.6 -ltk8.6"
make
获取编译错误::
gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -DWITH_APPINIT=1 -I./Include -I/home/*****e/python/python35/include -I. -IInclude -I/usr/local/include -I/home/*****e/python/src/Python-3.5.2/Include -I/home/*****e/python/src/Python-3.5.2 -c /home/*****e/python/src/Python-3.5.2/Modules/_tkinter.c -o build/temp.linux-x86_64-3.5/home/*****e/python/src/Python-3.5.2/Modules/_tkinter.o -I/opt/software/tсltk8.5/include
/home/*****e/python/src/Python-3.5.2/Modules/_tkinter.c:49:17: fatal error: tcl.h: No such file or directory
#include <tcl.h>
compilation terminated.
Failed to build these modules:
_tkinter
之后,我编辑文件
/home/.../Modules/_tkinter.c
并编写绝对路径
#include </opt/software/tсltk8.6/include/tcl.h>
#include </opt/software/tсltk8.6/include/tk.h>
结果,编译继续进行,但仍停留在此
-o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
gcc -pthread -o Programs/_freeze_importlib Programs/_freeze_importlib.o Modules/getbuildinfo.o Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o Objects/abstract.o Objects/accu.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/capsule.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/weakrefobject.o Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/bltinmodule.o Python/ceval.o Python/compile.o Python/codecs.o Python/dynamic_annotations.o Python/errors.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/graminit.o Python/import.o Python/importdl.o Python/marshal.o Python/modsupport.o Python/mystrtoul.o Python/mysnprintf.o Python/peephole.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/random.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/dynload_shlib.o Python/thread.o Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o Modules/_threadmodule.o Modules/signalmodule.o Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/_stat.o Modules/timemodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/zipimport.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/hashtable.o Modules/symtablemodule.o Modules/_tkinter.o Modules/tkappinit.o Modules/xxsubtype.o -lpthread -ldl -lutil -L/opt/software/tcltk8.6/lib -ltk8.6.8 -ltcl8.6.8 -lX11 -lm
/usr/bin/ld: cannot find -ltk8.6.8
/usr/bin/ld: cannot find -ltcl8.6.8
collect2: error: ld returned 1 exit status
在这种情况下,我该怎么办?为什么在/usr/bin/ld
中看起来tcl和tk
tcl和tk安装在:
/opt/software/tcltk8.6
Python的源代码:
~/python/src/Python-3.5.2
答案 0 :(得分:0)
我找到了解决方案。您应该将所有软件包安装在公共目录中
sqlite3安装:
./configure --prefix=/path/to/python/installation/homedir
make -j && make install
tcl安装:
./configure --prefix=/path/to/python/installation/homedir
make -j && make install
tk安装:
./configure --prefix=/path/to/python/installation/homedir --with-tcl=/path/to/tcl/source/tcl8.6.8/unix
make -j && make install
在安装Python之前,您应该设置环境变量:
export LD_LIBRARY=/path/to/python/installation/homedir/lib
export TK_LIBRARY=/path/to/python/installation/homedir/lib
编辑setup.py
文件并将sqlite3 lib的路径添加到数组:
sqlite_inc_paths = [ '/usr/include',
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
'/path/to/python/installation/homedir/include',
]
和Python安装:
./configure \
--prefix=path/to/python/installation/homedir \
make -j && make install
在那之后,一切都会正确的。