markdown 在Ubuntu上安装pyenv

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在Ubuntu上安装pyenv相关的知识,希望对你有一定的参考价值。

# [pyenv](https://github.com/pyenv/pyenv)

## install

```shell
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
```

add `pyenv` command into path

```shell
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
```

restart shell, then enjoiy the `pyenv`

```shell
exec "$SHELL"
```

## install python env

see all versions which are able to install

```shell
pyenv install --list
```

pick one to install

```shell
pyenv install 3.5-dev
```

success ouput

```plain
Cloning https://github.com/python/cpython...
Installing Python-3.5-dev...
Installed Python-3.5-dev to /home/ubuntu/.pyenv/versions/3.5-dev
```

## troubleshoting

### build fail

similar ouput

```plain
Installing Python-3.4.3...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
 
Please consult to the Wiki page to fix the problem.
https://github.com/yyuu/pyenv/wiki/Common-build-problems
BUILD FAILED (Ubuntu 15.04 using python-build 20150601-11-g36c5cbf)
 
Inspect or clean up the working tree at /tmp/python-build.20150709085352.14078
Results logged to /tmp/python-build.20150709085352.14078.log
 
Last 10 log lines:
(cd /home/bjlee/.pyenv/versions/3.4.3/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS
```

run below comman to fix it

```shell
sudo apt-get install libreadline-gplv2-dev
sudo apt-get install libssl-dev libsqlite3-dev libbz2-dev
```

以上是关于markdown 在Ubuntu上安装pyenv的主要内容,如果未能解决你的问题,请参考以下文章

sh 在Ubuntu 14.04上使用pyenv安装python 2.7.10

Ubuntu系统安装Pyenv

Ubuntu下安装pyenv管理多版本python

Ubuntu安装Python版本管理工具pyenv

Ubuntu下安装Pyenv不成功,求指教

为啥我不能“停用”pyenv / virtualenv?如何“修复”安装