deepin(Linux)使用pyenv安装Python3.7.4

发现刚刚安装的deepin自带的Python2.73.5的版本的,有点嫌弃3.5的,于是想安装一个比较新鲜的py,但是怕升级后出现各种依赖问题,就打算适用pyenv来安装(配合pycharm适用,其自带的env功能有限)

一、正题

1.安装git:

sudo apt-get update
sudo apt-get install git

2. 安装pyenv:

git clone https://github.com/yyuu/pyenv.git ~/.pyenv 
# 向~/.bashrc 添加环境变量,也可使用vim编辑~/.bashrc来添加
echo 'export PATH=~/.pyenv/bin:$PATH' >> ~/.bashrc 
echo 'export PYENV_ROOT=~/.pyenv' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

* 注意:这里你可能会出现command not found: shoptcommand not found: complete问题

不要担心这是因为你使用的是zsh才会出现的,如果你在bash里执行source ~/.bashrc就不会出错
具体问题请查看此处

3.使用pyenv安装python 3.7.4:

# 无代理
pyenv install 3.7.4
# 有代理
PYTHON_CONFIGURE_OPTS="--disable-ipv6"  proxychains4 pyenv install 3.7.4

* 这里它是从pyhton官网上下载的,可能速度比较慢,使用proxychains4代理比较快
* 如果加代理不加上PYTHON_CONFIGURE_OPTS="--disable-ipv6"参数会安装失败出现Fatal: You must get working getaddrinfo() function. or you can specify "--disable-ipv6". 具体问题请查看 此处

可能的问题:
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd                
time                                                           


Failed to build these modules:
_ctypes                                                        


Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
                          
解决:
#  安装依赖,重新尝试安装
sudo apt-get install libffi-dev -y

* 如果还是安装出错,还是同一个问题继续安装基础包

sudo apt-get install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
sudo apt-get install install make curl curl-devel gcc gcc-c++ gcc-g77 gcc* make zlib-devel bzip2-devel openssl-devel xz-libs wget unzip xz vixie-cron crontabs ntpdate tar lrzsz sysstat bind-utils vim -y

* *如果还是安装出错可参考参考 [这里] (https://jameskiefer.com/posts/installing-python-3.7-on-debian-8/) *

Good Luck!

pyenv 常用命令

pyenv install --list  # 列出可供安装的 python 版本 
pyenv install <version>  # 安装指定版本的 
python pyenv local <version>  # 在当前目录下设置 python 版本 
pyenv versions  # 列出系统中安装的 python 版本 
pyenv version  # 显示当前目录下采用的 python 

参考:
pyenv 安装及常用命令
使用pyenv与pyenv-virtualenv管理python环境
inux 解决 " command not found: shopt "的 "~/.bashrc" 配置问题
安装python3.7出现ModuleNotFoundError: No module named '_ctypes'报错

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。