当前位置:   article > 正文

Linux 环境搭建Python3环境_metadata-generation-failed

metadata-generation-failed

前言:

  目前服务器为centos6.9, 系统自带的python的版本为2.6.x,这时我们需要用到Python3 和 pip3,但是原有的Python2 和pip2也得用,也就是说python3 and python2 共存,pip2 and pip3共存,下面文章将会介绍:

1、先到官方网站下载python3的安装包      

    wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz

    https://www.python.org/ftp/python/3.9.10/Python-3.9.10.tgz 

2、解压包

     tar -xf Python-3.6.6.tar.xz

3、安装依赖

  1. yum install openssl-devel -y
  2. yum install zlib-devel -y
  3. yum install libffi-devel -y

4、编译安装

  1. cd Python-3.9.10
  2. ./configure --prefix=/usr/local/Python-3.9.10 #安装目录可以自己定义无所谓。
  3. make && make install

5、编译完成后会在如 /opt/下生成Python的文件夹 ,自定义软连接:
     ln -s /usr/local/Python-3.9.10/bin/python3 /usr/bin/python3

测试python3安装是否正常:

6、python3的安装已经完成,接下来给python3安装pip3

yum install python3-pip

7、测试是否安装成功

   pip3 -V         #检查版本
   pip 8.0.2 from /opt/Python/lib/python3.6/site-packages/pip-8.0.2-py3.6.egg (python 3.6)

   使用pip3安装pymysql模块

   pip3 install pymysql

  1. [root@192.168.200.143 /opt/Python/bin]$ pip3 install pymysql
  2. Collecting pymysql
  3. Cache entry deserialization failed, entry ignored
  4. Cache entry deserialization failed, entry ignored
  5. Downloading https://files.pythonhosted.org/packages/a7/7d/682c4a7da195a678047c8f1c51bb7682aaedee1dca7547883c3993ca9282/PyMySQL-0.9.2-py2.py3-none-any.whl (47kB)
  6. 100% |████████████████████████████████| 49kB 349kB/s
  7. Requirement already satisfied (use --upgrade to upgrade): cryptography in /opt/Python/lib/python3.6/site-packages (from pymysql)
  8. Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /opt/Python/lib/python3.6/site-packages (from cryptography->pymysql)
  9. Requirement already satisfied (use --upgrade to upgrade): cffi!=1.11.3,>=1.7 in /opt/Python/lib/python3.6/site-packages (from cryptography->pymysql)
  10. Requirement already satisfied (use --upgrade to upgrade): idna>=2.1 in /opt/Python/lib/python3.6/site-packages (from cryptography->pymysql)
  11. Requirement already satisfied (use --upgrade to upgrade): asn1crypto>=0.21.0 in /opt/Python/lib/python3.6/site-packages (from cryptography->pymysql)
  12. Requirement already satisfied (use --upgrade to upgrade): pycparser in /opt/Python/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography->pymysql)
  13. Installing collected packages: pymysql
  14. Successfully installed pymysql-0.9.2
  15. You are using pip version 8.0.2, however version 18.0 is available.
  16. You should consider upgrading via the 'pip install --upgrade pip' command.

  安装完毕后,进入到python3查看使用pip3安装的pymysql模块是否可以被python3导入:

  1. [root@192.168.200.143 /opt/Python/bin]$ python3
  2. Python 3.6.6 (default, Jul 27 2018, 02:57:12)
  3. [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import pymysql
  6. >>> exit(

  OK 完成 ~~

8、报错 "error: metadata-generation-failed"

解决方法:pip3 install --upgrade setuptools

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/490972
推荐阅读
相关标签
  

闽ICP备14008679号