ubuntu安裝python-dev煞烫,首先需要的是換源,換成國(guó)內(nèi)的源
cd /etc/apt/
cp sources.list source.list.bak
vim sources.list
修改為如下的源:
deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
然后在安裝過(guò)程中會(huì)出現(xiàn)依賴問(wèn)題:
方法一:
使用aptitude解決問(wèn)題:
- 1.安裝 aptitude
sudo apt-get install aptitude
- 2.然后用aptitude安裝python-dev
sudo aptitude install python-dev
然后在出現(xiàn)的選擇中依次選擇 n , y , y 秆剪,這樣會(huì)自動(dòng)解決依賴問(wèn)題衩侥,可以升級(jí)或者降級(jí)需要的版本茫藏。
方法二:
使用pyenv民鼓,可以安裝多版本的python
- 1.安裝 pyenv
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
- 2.安裝完成后,根據(jù)提示將如下語(yǔ)句加入到 ~/.bashrc 中:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)" # 這句可以不加
然后重啟終端即可蓬抄。
查看可安裝的版本
$ pyenv install --list
安裝對(duì)應(yīng)的版本
$ pyenv install 2.7.5 -v
方法三
echo "deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted" | sudo tee -a /etc/apt/sources.list.d/precise-updates.list
sudo apt-get update
sudo apt-get install python2.7-dev
sudo apt-get install python-dev