ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

如何用源代码安装Python 3.8.1

2020-01-29 16:04:16  阅读:1173  来源: 互联网

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


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

安装python3.8.1的过程如下:

  1. 官网下载源代码包
  2. 解压
  3. 进入目录Python-3.8.1
  4. 按照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('"'"'\r\n'"'"', '"'"'\n'"'"');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 "<string>", line 1, in <module>
      File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in <module>
        from setuptools.dist import Distribution, Feature
      File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 35, in <module>
        from setuptools import windows_support
      File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
        import ctypes
      File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
        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 
dingdingfish 博客专家 发布了377 篇原创文章 · 获赞 43 · 访问量 55万+ 他的留言板 关注

标签:__,Python,py,devel,pyinputplus,install,pip,源代码,3.8
来源: https://blog.csdn.net/stevensxiao/article/details/104107512

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有