python项目---数据可视化(01)

      现在开始,根据《python编程从入门到实践》这本书上的目开始练习Python。做以下笔记:

一. 采用whl形式安装matplotlib(未成功)

1. 下载whl安装包

wget https://files.pythonhosted.org/packages/da/1d/e6d9af0b5045597869537391f1036ab841c613c3f3e40f16bbc1d75450ee/matplotlib-2.2.2-cp37-cp37m-manylinux1_x86_64.whl

    note:要Linux源码包

2. 查看下载的文件,是以whl结尾的,因此需要采用pip命令进行安装

whl文件是Python的第三方模块的安装文件,一般在pypi网站上提供下载,所以whl文件是通过Python的pip命令进行安装的。方法是先用cd命令切换到whl文件所在的目录,然后执行pip命令,类似于这样:
pip install whl文件名   (note:pip类似RedHat里面的yum,安装软件非常方便)

3. 安装pip

   (1)下载源码包

      wget https://files.pythonhosted.org/packages/69/81/52b68d0a4de760a2f1979b0931ba7889202f302072cc7a0d614211bc7579/pip-18.0.tar.gz

   (2) 进入到源码包中并解压安装

 

然后再执行   python3 setup.py install    //则可以将第三方库安装到python中。

说明已经成功安装好了pip

(3)安装上面的matplotlib

   pip install matplotlib......又出错了,需要现状wheel

(4)安装wheel

    为什么需要安装wheel,因为上面下载的文件的后缀是whl。参考https://blog.csdn.net/deranotoo/article/details/53400098

   pip install wheel,结果报错如下,

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

参考如下解决办法:

 https://www.cnblogs.com/mlgjb/p/7976561.html

本人实在无法理解为什么会报错,因为ssl模块确实在lib/python3.6这个目录下,求助度娘后,才知道python中要使用ssl需要有openssl作为前置,于是安装openssl,但是发现openssl已经安装了,进入到系统自带那个python2.7中,发现导入ssl没有报错。

到这个时候已经能大致确定原因了,就是python3在安装的过程中无法使用openssl,根据网上的一些博客的做法,要进入到python源码包解压后的那个目录下的Modules/Setup,注意Setup这个文件,只有在python完成安装后才会生成这个文件。

用vim编辑,找到上图部分,把上图横线部分部分的#给去掉。

然后再编译 make。

安装  make install。

但是这个时候又特么悲剧的报错了,说是找不到openssl/rsa这个文件,百度之后,说是缺少openssl的开发包,因为你尝试编译的程序使用openssl,但是缺少和openssl链接的库与头文件,需要安装openssl的开发包。

安装:yum install openssl-devel   (note: 我用的是centos7+VM)

再来编译 make

安装  make install

这两步是对已近安装的python再进行覆盖安装。

到此为止问题就解决了。

总结一下:

当你发现无法导入ssl的时候,首先检查一下,是否安装了openssl,再来检查一下是否安装openssl的开发包。

  (5)采用Pip安装matplotlib

 执行pip install matplotlib

  

暂时没解决。。。。。。。。。。。。貌似是版本不匹配什么的????????????不知道谁能指导下???

二. 采用matplotlib的source安装,直接下载官网的source版本,跟着官方说明进行

三. 采用已有的包来安装

执行上面黄色部分命令,就可以安装成功

note: 执行alias python=python3  可以临时更改默认的Python执行方式

 如果想要永久改变,可以将这个添加到  Place this into ~/.bashrc or ~/.bash_aliases file:

引用:

“A simple safe way would be to use an alias. Place this into ~/.bashrc or ~/.bash_aliases file:

alias python=python3

After adding the above in the file, run the command below:

source ~/.bash_aliases or source ~/.bashrc   ”
原文地址:https://www.cnblogs.com/Hermioner/p/9441607.html