日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Linux系統(tǒng)安裝Python3環(huán)境

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

成都創(chuàng)新互聯(lián)公司是一家專業(yè)提供石臺(tái)企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站制作、成都做網(wǎng)站、H5頁面制作、小程序制作等業(yè)務(wù)。10年已為石臺(tái)眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計(jì)公司優(yōu)惠進(jìn)行中。

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/,找到對應(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需要的依賴。成功后(Complete!),如圖:

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

如果遇到如下問題: 

 
 
 
 
  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名稱不一定完全一樣。我的配置如下: 

 
 
 
 
  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)建軟鏈接

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

此時(shí),我們在命令窗口運(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,打開配置文件,添加如下配置: 

 
 
 
 
  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命令,查看是否配置成功,如圖:


網(wǎng)站題目:Linux系統(tǒng)安裝Python3環(huán)境
網(wǎng)址分享:http://www.5511xx.com/article/cdejsdd.html