centos pyenv python3.7

python版本管理使用

 

安装依赖

sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel

克隆pyenv

git clone git://github.com/yyuu/pyenv.git ~/.pyenv  
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc  
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc  
echo 'eval "$(pyenv init -)"' >> ~/.bashrc  
exec $SHELL -l 

  

安装python

查询python版本

pyenv install --list
Available versions:
  2.1.3
  2.2.3
  2.3.7
  2.4.0
  2.4.1
  2.4.2
  2.4.3
  2.4.4
  2.4.5
  2.4.6

  

国外源速度比较慢,提前下载python

mkdir ~/.pyenv/cache 
cd ~/.pyenv/cache
wget https://mirror.bjtu.edu.cn/python/3.7.0/Python-3.7.0.tar.xz

  

报错 

ModuleNotFoundError: No module named '_ctypes'
    import pip._internal
  File "/tmp/tmphc0uj1gm/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/__init__.py", line 42, in <module>
  File "/tmp/tmphc0uj1gm/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/cmdoptions.py", line 16, in <module>
  File "/tmp/tmphc0uj1gm/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/index.py", line 25, in <module>
  File "/tmp/tmphc0uj1gm/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/download.py", line 39, in <module>
  File "/tmp/tmphc0uj1gm/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in <module>
  File "/tmp/python-build.20201113164941.15116/Python-3.7.0/Lib/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

  

安装 libffi-devel 

yum install libffi-devel 

  

重新安装python

pyenv install 3.7.0
Installing Python-3.7.0...
Installed Python-3.7.0 to /root/.pyenv/versions/3.7.0

  

安装成功

上一篇:centos安装pyenv以及python3.7.4


下一篇:linux:系统启动流程