在CentOS6上安裝Python2.7的解決方法
在CentOS6上yum安裝工具是基于Python2.6.6的,所以在CentOS6上默認安裝的是Python2.6.6,因為要在服務器系統(tǒng)為CentOS6上部署生產(chǎn)環(huán)境,但是代碼都是基于Python2.7寫的,所有遇到了問題。
探索
發(fā)現(xiàn)系統(tǒng)不能卸載Python2.6后,查了系統(tǒng)的版本號
cat /etc/*-release
發(fā)現(xiàn)系統(tǒng)版本為CentOS6,于是開始Google搜索怎么解決。
解決辦法
重新手動裝一個Python2.7
準備階段
# 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)建一個虛擬環(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
總結
以上所述是小編給大家介紹的在CentOS6上安裝Python2.7的解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關文章
淺談python中統(tǒng)計計數(shù)的幾種方法和Counter詳解
今天小編就為大家分享一篇淺談python中統(tǒng)計計數(shù)的幾種方法和Counter詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11python中sklearn庫predict及python sklearn linearmodel(
Scikit-learn(sklearn)是機器學習中常用的第三方模塊,對常用的機器學習方法進行了封裝,包括回歸(Regression)、降維(Dimensionality Reduction)、分類(Classfication)、聚類(Clustering)等方法,今天小編給大家分享python中sklearn庫predict的問題,感興趣的朋友一起看看吧2024-02-02python操作小程序云數(shù)據(jù)庫實現(xiàn)簡單的增刪改查功能
這篇文章主要介紹了python操作小程序云數(shù)據(jù)庫實現(xiàn)簡單的增刪改查功能,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-06-06詳解Python 2.6 升級至 Python 2.7 的實踐心得
本篇文章主要介紹了詳解Python 2.6 升級至 Python 2.7 的實踐心得,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04Pytorch在dataloader類中設置shuffle的隨機數(shù)種子方式
今天小編就為大家分享一篇Pytorch在dataloader類中設置shuffle的隨機數(shù)種子方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01python實現(xiàn)list由于numpy array的轉換
下面小編就為大家分享一篇python實現(xiàn)list由于numpy array的轉換方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-04-04