自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux系統(tǒng)安裝Python3環(huán)境

開(kāi)發(fā) 后端 Linux
我們看到Linux中已經(jīng)自帶了Python2.7.5。再次運(yùn)行python命令后就可以使用python命令窗口了(Ctrl+D退出python命令窗口)。

 本文基于如下Linux系統(tǒng)版本:

1、默認(rèn)情況下,Linux會(huì)自帶安裝Python,可以運(yùn)行python --version命令查看,如圖:

我們看到Linux中已經(jīng)自帶了Python2.7.5。再次運(yùn)行python命令后就可以使用python命令窗口了(Ctrl+D退出python命令窗口)。

2、查看Linux默認(rèn)安裝的Python位置

看到/usr/bin/python和/usr/bin/python2都是軟鏈接,/usr/bin/python指向/usr/bin/python2,而/usr/bin/python2最終又指向/usr/bin/python2.7。所以運(yùn)行python/python2/python2.7是一樣的,如圖:

3、安裝python3

(1)登錄https://www.python.org/downloads/source/,找到對(duì)應(yīng)版本(我們以Python 3.6.5為例)如圖:

下載Python-3.6.5.tgz

(2)文件上傳

將文件上傳到Linux系統(tǒng)的某個(gè)目錄下,根據(jù)自己情況上傳,本例上傳到了/root/tools目錄下,如圖:

(3)解壓

執(zhí)行tar -zxvf Python-3.6.5.tgz命令,將文件解壓到當(dāng)前目錄,如圖:

(4)準(zhǔn)備編譯環(huán)境

執(zhí)行如下命令: 

  1. yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make 

安裝python需要的依賴(lài)。成功后(Complete!),如圖:

如果python是3.7版本,還需要安裝libffi-devel。整個(gè)編譯過(guò)程1分鐘左右。

如果遇到如下問(wèn)題: 

  1. Loaded plugins: fastestmirror  
  2.  00:00:00       
  3. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was  
  4. 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"  
  5.  One of the configured repositories failed (Unknown),  
  6.  and yum doesn't have enough cached data to continue. At this point the only  
  7.  safe thing yum can do is fail. There are a few ways to work "fix" this:  
  8.      1. Contact the upstream for the repository and get them to fix the problem.  
  9.      2. Reconfigure the baseurl/etc. for the repository, to point to a working  
  10.         upstream. This is most often useful if you are using a newer  
  11.         distribution release than is supported by the repository (and the  
  12.         packages for the previous distribution release still work). 

一般是不能連接外網(wǎng),每個(gè)情況不一樣,我的解決方案,執(zhí)行如下命令 

  1. vi  /etc/sysconfig/network-scripts/ifcfg-ens33 

每個(gè)人的Linux中ifcfg-ens33名稱(chēng)不一定完全一樣。我的配置如下: 

  1. TYPE=Ethernet  
  2. PROXY_METHOD=none  
  3. BROWSER_ONLY=no  
  4. #BOOTPROTO=none  
  5. DEFROUTE=yes  
  6. IPV4_FAILURE_FATAL=no  
  7. IPV6INIT=yes  
  8. IPV6_AUTOCONF=yes  
  9. IPV6_DEFROUTE=yes  
  10. IPV6_FAILURE_FATAL=no  
  11. IPV6_ADDR_GEN_MODE=stable-privacy  
  12. NAME=ens33  
  13. UUID=296fb7a9-961a-46ea-bc1b-678cca49d40a  
  14. DEVICE=ens33  
  15. ONBOOT=yes  
  16. IPADDR=192.168.189.111  
  17. GATEWAY=192.168.189.2  
  18. NETMASK=255.255.255.0  
  19. DNS1=8.8.8.8  
  20. PREFIX=24  
  21. IPV6_PRIVACY=no 

配置好保存,執(zhí)行service network restart重啟網(wǎng)絡(luò)服務(wù)。然后再重新執(zhí)行上面的yum安裝命令即可。

(5)編譯安裝

執(zhí)行cd Python-3.6.5進(jìn)入解壓后的Python-3.6.5目錄下,依次執(zhí)行如下三個(gè)命令: 

  1. ./configure --prefix=/root/training/Python-3.6.5  
  2. make  
  3. make install 

其中--prefix是Python的安裝目錄,安裝成功后,如圖:

我們看到,同時(shí)安裝了setuptools和pip工具。進(jìn)入到/root/training/Python-3.6.5安裝目錄,如圖:

(6)創(chuàng)建軟鏈接

還記得開(kāi)始,Linux已經(jīng)安裝了python2.7.5,這里我們不能將它刪除,如果刪除,系統(tǒng)可能會(huì)出現(xiàn)問(wèn)題。我們只需要按照與Python2.7.5相同的方式為Python3.6.5創(chuàng)建一個(gè)軟鏈接即可,我們把軟鏈接放到/usr/local/bin目錄下,如圖:

此時(shí),我們?cè)诿畲翱谶\(yùn)行python3,如圖:

安裝成功!當(dāng)然此時(shí)還是可以使用Python2.7.5版本(運(yùn)行python/python2/python2.7即可)。

(7)配置環(huán)境變量

配置環(huán)境變量主要是能快速使用pip3安裝命令。

執(zhí)行 vi ~/.bash_profile,打開(kāi)配置文件,添加如下配置: 

  1. #配置python  
  2. export PYTHON_HOME=/root/training/Python-3.6.5  
  3. export PATH=$PYTHON_HOME/bin:$PATH 

保存退出(:wq),執(zhí)行source ~/.bash_profile命令使配置生效。執(zhí)行echo命令,查看是否配置成功,如圖:

 

 

責(zé)任編輯:龐桂玉 來(lái)源: 運(yùn)維派
相關(guān)推薦

2010-01-13 17:18:53

CentOS 4.5環(huán)

2009-07-24 18:03:44

2017-06-26 18:30:01

PythonLinuxCentos

2009-12-18 11:14:52

VS 2010環(huán)境

2009-12-15 18:00:54

.NET 4.0

2011-08-04 18:09:15

PHP

2021-02-14 10:03:41

網(wǎng)絡(luò)攻擊零日漏洞SolarWinds

2009-12-15 10:41:06

Visual Stud

2011-06-17 17:32:25

Qt Visual C++

2009-12-03 14:37:02

Visual Stud

2009-12-15 17:25:09

2012-09-19 20:40:53

2023-05-09 15:17:42

Hi3861鴻蒙

2011-09-01 14:58:05

Ubuntuwin7

2011-06-28 09:20:41

Qt Qt 4.3.2 Visual Stu

2011-07-28 16:45:40

Win7 iPhone SDK

2009-12-17 14:01:44

Visual Stud

2011-12-27 09:56:14

Java

2010-08-04 10:04:52

Flex1.5環(huán)境配置

2011-04-06 10:38:19

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)