在CentOS6上安裝Python2.7的解決方法
在CentOS6上yum安裝工具是基于Python2.6.6的,所以在CentOS6上默認(rèn)安裝的是Python2.6.6,因?yàn)橐诜?wù)器系統(tǒng)為CentOS6上部署生產(chǎn)環(huán)境,但是代碼都是基于Python2.7寫的,所有遇到了問題。
探索
發(fā)現(xiàn)系統(tǒng)不能卸載Python2.6后,查了系統(tǒng)的版本號(hào)
cat /etc/*-release
發(fā)現(xiàn)系統(tǒng)版本為CentOS6,于是開始Google搜索怎么解決。
解決辦法
重新手動(dòng)裝一個(gè)Python2.7
準(zhǔn)備階段
# Start by making sure your system is up-to-date: yum update # Compilers and related tools: yum groupinstall -y "development tools" # Libraries needed during compilation to enable all features of Python: yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel # If you are on a clean "minimal" install of CentOS you also need the wget tool: yum install -y wget
安裝Python
下載python2.7并安裝
# Get Python 2.7.14: wget http://python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz tar xf Python-2.7.14.tar.xz cd Python-2.7.14 ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" make && make altinstall
安裝Pip
# First get the script: wget https://bootstrap.pypa.io/get-pip.py # Then execute it using Python 2.7 python2.7 get-pip.py # With pip installed you can now do things like this: pip2.7 install [packagename] pip2.7 install --upgrade [packagename] pip2.7 uninstall [packagename]
創(chuàng)建虛擬環(huán)境
最后可以利用venv創(chuàng)建一個(gè)虛擬環(huán)境(畢竟Python2.6你不能卸載)
# Install virtualenv for Python 2.7 and create a sandbox called my27project: pip2.7 install virtualenv virtualenv my27project 試一下? # Check the system Python interpreter version: python --version # This will show Python 2.6.6 # Activate the my27project sandbox: source my27project/bin/activate # This will show Python 2.7.4 python --version
總結(jié)
以上所述是小編給大家介紹的在CentOS6上安裝Python2.7的解決方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Python:二維列表下標(biāo)互換方式(矩陣轉(zhuǎn)置)
今天小編就為大家分享一篇Python:二維列表下標(biāo)互換方式(矩陣轉(zhuǎn)置),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-12-12
PyTorch實(shí)現(xiàn)圖像識(shí)別實(shí)戰(zhàn)指南
圖像識(shí)別是從給定圖像中提取有意義的信息(例如圖像內(nèi)容)的過程,下面這篇文章主要給大家介紹了關(guān)于PyTorch實(shí)現(xiàn)圖像識(shí)別的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-02-02
redis數(shù)據(jù)庫及與python交互用法簡單示例
這篇文章主要介紹了redis數(shù)據(jù)庫及與python交互用法,結(jié)合實(shí)例形式分析了Redis數(shù)據(jù)庫的基本類型、操作以及Python針對(duì)Redis數(shù)據(jù)庫的連接、增刪改查等相關(guān)操作技巧,需要的朋友可以參考下2019-11-11
python使用urllib模塊和pyquery實(shí)現(xiàn)阿里巴巴排名查詢
這篇文章主要介紹了python庫urllib及pyquery基本東西的應(yīng)用,實(shí)現(xiàn)阿里巴巴關(guān)鍵詞排名的查詢,其中涉及到urllib代理的設(shè)置,pyquery對(duì)html文檔的解析2014-01-01
Scrapy爬蟲多線程導(dǎo)致抓取錯(cuò)亂的問題解決
本文針對(duì)Scrapy爬蟲多線程導(dǎo)致抓取錯(cuò)亂的問題進(jìn)行了深入分析,并提出了相應(yīng)的解決方案,具有一定的參考價(jià)值,感興趣的可以了解一下2023-11-11

