linux中python安装,linuxpython安装,1、查看当前环境中是
linux中python安装,linuxpython安装,1、查看当前环境中是
1、查看当前环境中是否存在python安装包
[[email protected] ~]$ rpm -qa | grep pythongnome-python2-gnome-2.28.0-3.el6.x86_64python-slip-0.2.20-1.el6_2.noarchpython-iniparse-0.3.1-2.1.el6.noarchpython-pycurl-7.19.0-9.el6.x86_64gnome-python2-gconf-2.28.0-3.el6.x86_64gnome-python2-extras-2.25.3-20.el6.x86_64gnome-python2-libegg-2.25.3-20.el6.x86_64notify-python-0.1.1-10.el6.x86_64python-libs-2.6.6-66.el6_8.x86_64python-ethtool-0.6-6.el6.x86_64python-mako-0.3.4-1.el6.noarchabrt-python-2.0.8-43.el6.centos.x86_64gnome-python2-gnomekeyring-2.28.0-5.el6.x86_64gnome-python2-bonobo-2.28.0-3.el6.x86_64python-meh-0.12.1-3.el6.noarchpython-2.6.6-66.el6_8.x86_64libuser-python-0.56.13-8.el6_7.x86_64
2、在官网上查看最新的版本;也可以通过yum install 安装python安装包,但是有可能yum源上面没有最新的python版本,所以采用下载的方式安装最新的安装包。
https://www.python.org/downloads/source/
[[email protected] home]# yum info python //查看yum源上的py安装包信息Failed to set locale, defaulting to CLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comInstalled PackagesName : pythonArch : x86_64Version : 2.6.6Release : 66.el6_8Size : 78 kRepo : installedFrom repo : anaconda-CentOS-201703281317.x86_64Summary : An interpreted, interactive, object-oriented programming languageURL : http://www.python.org/License : PythonDescription : Python is an interpreted, interactive, object-oriented programming : language often compared to Tcl, Perl, Scheme or Java. Python includes : modules, classes, exceptions, very high level dynamic data types and : dynamic typing. Python supports interfaces to many system calls and : libraries, as well as to various windowing systems (X11, Motif, Tk, : Mac and MFC). : : Programmers can write new built-in modules for Python in C or C++. : Python can be used as an extension language for applications that need : a programmable interface. : : Note that documentation for Python is provided in the python-docs : package. : : This package provides the "python" executable; most of the actual : implementation is within the "python-libs" package.[[email protected] home]# [[email protected] home]# yum search python3 //查询yum源是否有?Failed to set locale, defaulting to CLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comWarning: No matches found for: python3No Matches found
3、安装python源码:
下载:将安装包上传到linux的家目录下
[[email protected] home]# cd zyj[[email protected] zyj]# lltotal 31312drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Desktopdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Documentsdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Downloadsdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Musicdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Picturesdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Public-rw-rw-r--. 1 zyj zyj 22994617 May 1 2018 Python-3.6.5.tgzdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Templatesdrwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Videos-rw-rw-r--. 1 zyj zyj 9034460 Apr 27 21:23 mysql-server-5.1.73-8.el6_8.x86_64.rpm[[email protected] zyj]# mv Python-3.6.5.tgz ../[[email protected] home]# lltotal 22472-rwxrwxrwx. 1 root root 10 Apr 25 11:05 1.txt-rw-rw-r--. 1 zyj zyj 22994617 May 1 2018 Python-3.6.5.tgz-rwxrwxrwx. 1 zyj zyj 86 Apr 15 09:23 hello.txtdrwxr-xrwx. 2 root root 4096 Apr 15 07:00 xdrwx------. 24 zyj zyj 4096 May 1 00:00 zyj查看源码(.c结尾为c语言):在windows下打开压缩包,查看里面文件的后缀。准备编译环境(检查c语言编译环境,gcc)
[[email protected] home]# rpm -qa | grep gcclibgcc-4.4.7-18.el6.x86_64gcc-4.4.7-18.el6.x86_64
[[email protected] home]# yum install gcc-c++ //安装c++编译环境检查(依赖、兼容),预编译:
[[email protected] home]# tar -zxvf Python-3.6.5.tgz //解压安装包[[email protected] home]# ls1.txt Python-3.6.5 Python-3.6.5.tgz hello.txt x zyj[[email protected] home]# cd Python-3.6.5 //进入安装包目录下[[email protected] Python-3.6.5]# lltotal 1036drwxr-xr-x. 18 sl sl 4096 Mar 28 03:24 Docdrwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Grammardrwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Include-rw-r--r--. 1 sl sl 12763 Mar 28 02:19 LICENSEdrwxr-xr-x. 33 sl sl 4096 Mar 28 02:19 Libdrwxr-xr-x. 8 sl sl 4096 Mar 28 02:19 Mac-rw-r--r--. 1 sl sl 61032 Mar 28 02:19 Makefile.pre.indrwxr-xr-x. 2 sl sl 4096 Mar 28 03:24 Miscdrwxr-xr-x. 13 sl sl 4096 Mar 28 02:19 Modulesdrwxr-xr-x. 4 sl sl 4096 Mar 28 02:19 Objectsdrwxr-xr-x. 6 sl sl 4096 Mar 28 02:19 PCdrwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 PCbuilddrwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Parserdrwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Programsdrwxr-xr-x. 3 sl sl 4096 Mar 28 02:19 Python-rw-r--r--. 1 sl sl 9281 Mar 28 02:19 README.rstdrwxr-xr-x. 23 sl sl 4096 Mar 28 02:19 Tools-rw-r--r--. 1 sl sl 13335 Mar 28 02:19 aclocal.m4-rwxr-xr-x. 1 sl sl 44259 Mar 28 02:19 config.guess-rwxr-xr-x. 1 sl sl 36515 Mar 28 02:19 config.sub-rwxr-xr-x. 1 sl sl 490243 Mar 28 02:19 configure-rw-r--r--. 1 sl sl 163178 Mar 28 02:19 configure.ac-rwxr-xr-x. 1 sl sl 7122 Mar 28 02:19 install-sh-rw-r--r--. 1 sl sl 42152 Mar 28 02:19 pyconfig.h.in-rw-r--r--. 1 sl sl 104570 Mar 28 02:19 setup.py
执行可执行文件:
[[email protected] Python-3.6.5]# ./configure --help`configure‘ configures python 3.6 to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them asVAR=VALUE. See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...‘ messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache‘ -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..‘]Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX]......Report bugs to <https://bugs.python.org/>.[[email protected] Python-3.6.5]# ./configure --prefix=/usr/python-3.6.5 //第三方软件安装在/usr/ 目录下。checking whether gcc -pthread supports computed gotos... yeschecking for build directories... donechecking for -O2... yeschecking for glibc _FORTIFY_SOURCE/memmove bug... nochecking for gcc ipa-pure-const bug... nochecking for stdatomic.h... nochecking for GCC >= 4.7 __atomic builtins... nochecking for ensurepip... upgradechecking if the dirent structure of a d_type field... yeschecking for the Linux getrandom() syscall... nochecking for the getrandom() function... noconfigure: creating ./config.statusconfig.status: creating Makefile.preconfig.status: creating Modules/Setup.configconfig.status: creating Misc/python.pcconfig.status: creating Misc/python-config.shconfig.status: creating Modules/ld_so_aixconfig.status: creating pyconfig.hcreating Modules/Setupcreating Modules/Setup.localcreating MakefileIf you want a release build with all stable optimizations active (PGO, etc),please run ./configure --enable-optimizations
准备安装依赖包:zlib、openssl。python的pip需要依赖这两个包。
[[email protected] home]# yum install zlib* openssl* //安装依赖包[[email protected] home]# cd Python-3.6.5[[email protected] Python-3.6.5]# lsDoc LICENSE Makefile Misc PC Programs Tools config.log configure pyconfig.hGrammar Lib Makefile.pre Modules PCbuild Python aclocal.m4 config.status configure.ac pyconfig.h.inInclude Mac Makefile.pre.in Objects Parser README.rst config.guess config.sub install-sh setup.py[[email protected] Python-3.6.5]# ./configure --prefix=/usr/python-3.6.5 --enable-optimizations //完整的预编译...creating Modules/Setupcreating Modules/Setup.localcreating Makefile //没有任何报错[[email protected] Python-3.6.5]#编译:make
[[email protected] Python-3.6.5]# make...make[1]: Entering directory `/home/Python-3.6.5‘find . -name ‘*.gc??‘ -exec rm -f {} ‘;‘find . -name ‘*.profclang?‘ -exec rm -f {} ‘;‘find . -name ‘*.dyn‘ -exec rm -f {} ‘;‘rm -f /home/Python-3.6.5/coverage.inform -rf /home/Python-3.6.5/lcov-reportmake[1]: Leaving directory `/home/Python-3.6.5‘[[email protected] Python-3.6.5]# //一般检查最后几行有没有error安装:make install
[[email protected] Python-3.6.5]#make install......Collecting setuptoolsCollecting pipInstalling collected packages: setuptools, pipSuccessfully installed pip-9.0.3 setuptools-39.0.1[[email protected] Python-3.6.5]#配置环境变量
linux中python安装
相关内容
- Windows10+Python3下安装NumPy+SciPy+Matplotlib,windows10numpy,Num
- Python3 Tkinter基础 Scale orient 横竖 resolution单步步长 leng
- Python第一天接触心得,python第一天心得,最近想学Pytho
- Python之CVXOPT模块,pythoncvxopt,??Python中支
- 复制一个Python全部环境到另一个环境,python另一个,导出
- mac下安装Python3.*(最新版本),macpython3.,前言:mac系统自
- Python3-实现钉钉报警,python3-报警,import req
- python关键字and和or用法实例,python关键字andor
- Python and、or以及and-or语法总结,pythonand-or
- Python处理RSS、ATOM模块FEEDPARSER介绍,atomfeedparser
评论关闭