python代码示例3.8-如何用源代码安装Python 3.8.1

最简单的方式当然是yum install python3了,但Oracle Linux默认安装的是3.6.8,而我想安装更新一些的版本。

安装python3.8.1的过程如下:

从官网下载源代码包

解压

进入目录Python-3.8.1

按照README.rst中的说明操作:

./configure

make

make test

sudo make install

最后两步的时间时间较长。

我安装时,在最后一步报错:

python 3.8.1 make install ModuleNotFoundError: No module named 'zlib'

安装zlib开发包后通过:

sudo yum install zlib-devel

安装后可执行程序为python3.8, 符号链接python3指向此文件:

$ python3 --version

Python 3.8.1

升级pip:

$ pip3 install --user --upgrade pip

Collecting pip

Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl

Installing collected packages: pip

Successfully installed pip-20.0.2

pip3安装某模块报错:

$ pip3 install --user pyinputplus

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

解决方法参见这里:

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

make

make install

pip3安装某模块再次报错:

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.

Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.

To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pyinputplus/

Collecting pyinputplus

Using cached PyInputPlus-0.2.8.tar.gz (20 kB)

ERROR: Command errored out with exit status 1:

command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hofx1t7q/pyinputplus/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hofx1t7q/pyinputplus/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"' '"'"', '"'"' '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-hofx1t7q/pyinputplus/pip-egg-info

cwd: /tmp/pip-install-hofx1t7q/pyinputplus/

Complete output (11 lines):

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in

from setuptools.dist import Distribution, Feature

File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 35, in

from setuptools import windows_support

File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in

import ctypes

File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in

from _ctypes import Union, Structure, Array

ModuleNotFoundError: No module named '_ctypes'

----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方法参见这里,安装以下包后重新安装Python:

$ sudo yum install libffi-devel

3_stevensxiao

17.png

dingdingfish

博客专家

发布了377 篇原创文章 · 获赞 43 · 访问量 55万+

他的留言板

关注

标签:__,Python,py,devel,pyinputplus,install,pip,源代码,3.8

来源: https://blog.csdn.net/stevensxiao/article/details/104107512

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值