linux安装python3.*,更换Python2.*
下载并解压:Python-3.5.7.tgz
1 [root@AH-aQYWTYSJZX01 python3]# ll2 total 20268
3 -rw-r----- 1 temp01 temp01 20753760 Jul 11 08:30 Python-3.5.7.tgz
4 [root@AH-aQYWTYSJZX01 python3]# tar -zxvf Python-3.5.7.tgz
5 ......
6 Python-3.5.7/Python/condvar.h
7 Python-3.5.7/Python/modsupport.c
8 Python-3.5.7/Python/compile.c
9 Python-3.5.7/Python/frozenmain.c
10 Python-3.5.7/Python/asdl.c
11 Python-3.5.7/Python/errors.c
12 Python-3.5.7/Python/getplatform.c
13 Python-3.5.7/Python/README
14 Python-3.5.7/Python/codecs.c
15 Python-3.5.7/Python/thread_pthread.h
16 Python-3.5.7/Python/Python-ast.c
17 Python-3.5.7/Python/ceval.c
18 Python-3.5.7/config.sub
19 Python-3.5.7/README
20 Python-3.5.7/Grammar/
21 Python-3.5.7/Grammar/Grammar
1 [root@AH-aQYWTYSJZX01 Python-3.5.7]# ./configure --prefix=/usr/local/python32 ......
3 checking for /dev/ptmx... yes
4 checking for /dev/ptc... no
5 checking for %lld and %llu printf() format support... yes
6 checking for %zd printf() format support... yes
7 checking for socklen_t... yes
8 checking for broken mbstowcs... no
9 checking for --with-computed-gotos... no value specified
10 checking whether gcc -pthread supports computed gotos... yes
11 checking for build directories... done
12 checking for -O2... yes
13 checking for glibc _FORTIFY_SOURCE/memmove bug... no
14 checking for gcc ipa-pure-const bug... no
15 checking for stdatomic.h... no
16 checking for GCC >= 4.7 __atomic builtins... no
17 checking for ensurepip... upgrade
18 checking if the dirent structure of a d_type field... yes
19 checking for the Linux getrandom() syscall... no
20 checking for the getrandom() function... no
21 configure: creating ./config.status
22 config.status: creating Makefile.pre
23 config.status: creating Modules/Setup.config
24 config.status: creating Misc/python.pc
25 config.status: creating Misc/python-config.sh
26 config.status: creating Modules/ld_so_aix
27 config.status: creating pyconfig.h
28 creating Modules/Setup
29 creating Modules/Setup.local
30 creating Makefile
31
32
33 If you want a release build with all stable optimizations active (PGO, etc),
34 please run ./configure --enable-optimizations
1 [root@AH-aQYWTYSJZX01 Python-3.5.7]# make2 ......
3 To find the necessary bits, look in setup.py in detect_modules() for the module's name.
4
5 The following modules found by detect_modules() in setup.py, have been
6 built by the Makefile instead, as configured by the Setup files:
7 atexit pwd time
8
9 Failed to build these modules:
10 _pickle
11
12 running build_scripts
13 creating build/scripts-3.5
14 copying and adjusting /sga/python3/Python-3.5.7/Tools/scripts/pydoc3 -> build/scripts-3.5
15 copying and adjusting /sga/python3/Python-3.5.7/Tools/scripts/idle3 -> build/scripts-3.5
16 copying and adjusting /sga/python3/Python-3.5.7/Tools/scripts/2to3 -> build/scripts-3.5
17 copying and adjusting /sga/python3/Python-3.5.7/Tools/scripts/pyvenv -> build/scripts-3.5
18 changing mode of build/scripts-3.5/pydoc3 from 640 to 755
19 changing mode of build/scripts-3.5/idle3 from 640 to 755
20 changing mode of build/scripts-3.5/2to3 from 640 to 755
21 changing mode of build/scripts-3.5/pyvenv from 640 to 755
22 renaming build/scripts-3.5/pydoc3 to build/scripts-3.5/pydoc3.5
23 renaming build/scripts-3.5/idle3 to build/scripts-3.5/idle3.5
24 renaming build/scripts-3.5/2to3 to build/scripts-3.5/2to3-3.5
25 renaming build/scripts-3.5/pyvenv to build/scripts-3.5/pyvenv-3.5
26 /usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
27 gcc -pthread -c -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -I./Include -DPy_BUILD_CORE -o Programs/_testembed.o ./Programs/_testembed.c
28 gcc -pthread -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.5m.a -lpthread -ldl -lutil -lrt -lm
29 # Substitution happens here, as the completely-expanded BINDIR
30 # is not available in configure
31 sed -e "s,@EXENAME@,/usr/local/python3/bin/python3.5m," < ./Misc/python-config.in >python-config.py
32 # Replace makefile compat. variable references with shell script compat. ones; ->
33 LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
34 # On Darwin, always use the python version of the script, the shell
35 # version doesn't use the compiler customizations that are provided
36 # in python (_osx_support.py).
37 if test `uname -s` = Darwin; then \
38 cp python-config.py python-config; \
39 fi
1 [root@AH-aQYWTYSJZX01 Python-3.5.7]# make install2 ......
3 if test "3.5" != "3.5m"; then \
4 rm -f /usr/local/python3/bin/python3.5-config; \
5 (cd /usr/local/python3/bin; ln -s python3.5m-config python3.5-config); \
6 rm -f /usr/local/python3/lib/pkgconfig/python-3.5m.pc; \
7 (cd /usr/local/python3/lib/pkgconfig; ln -s python-3.5.pc python-3.5m.pc); \
8 fi
9 rm -f /usr/local/python3/bin/python3-config
10 (cd /usr/local/python3/bin; ln -s python3.5-config python3-config)
11 rm -f /usr/local/python3/lib/pkgconfig/python3.pc
12 (cd /usr/local/python3/lib/pkgconfig; ln -s python-3.5.pc python3.pc)
13 rm -f /usr/local/python3/bin/idle3
14 (cd /usr/local/python3/bin; ln -s idle3.5 idle3)
15 rm -f /usr/local/python3/bin/pydoc3
16 (cd /usr/local/python3/bin; ln -s pydoc3.5 pydoc3)
17 rm -f /usr/local/python3/bin/2to3
18 (cd /usr/local/python3/bin; ln -s 2to3-3.5 2to3)
19 rm -f /usr/local/python3/bin/pyvenv
20 (cd /usr/local/python3/bin; ln -s pyvenv-3.5 pyvenv)
21 if test "x" != "x" ; then \
22 rm -f /usr/local/python3/bin/python3-32; \
23 (cd /usr/local/python3/bin; ln -s python3.5-32 python3-32) \
24 fi
25 rm -f /usr/local/python3/share/man/man1/python3.1
26 (cd /usr/local/python3/share/man/man1; ln -s python3.5.1 python3.1)
27 if test "xupgrade" != "xno" ; then \
28 case upgrade in \
29 upgrade) ensurepip="--upgrade" ;; \
30 install|*) ensurepip="" ;; \
31 esac; \
32 ./python -E -m ensurepip \
33 $ensurepip --root=/ ; \
34 fi
35 Collecting setuptools
36 Collecting pip
37 Installing collected packages: setuptools, pip
38 Successfully installed pip-9.0.1 setuptools-28.8.0
1 建立连接(将python3映射到python)2 [root@AH-aQYWTYSJZX01 Python-3.5.7]# mv /usr/bin/python /usr/bin/python.bak
3 [root@AH-aQYWTYSJZX01 Python-3.5.7]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
4 [root@AH-aQYWTYSJZX01 Python-3.5.7]#python
5 或
6 [root@AH-aQYWTYSJZX01 Python-3.5.7]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
7 [root@AH-aQYWTYSJZX01 Python-3.5.7]#python3
8
9 将/usr/local/python3/bin加入PATH
以上是 linux安装python3.*,更换Python2.* 的全部内容, 来源链接: utcz.com/z/386661.html