pip

几行代码完成动态图表绘制 | Python实战

偶尔善良 提交于 2020-12-06 11:45:35
作者 | 小F 来源 | 法纳斯特 头图 | CSDN下载自视觉中国 关于动态条形图,小F以前推荐过「Bar Chart Race」这个库。三行代码就能实现动态条形图的绘制。 有些同学在使用的时候,会出现一些错误。一个是加载文件报错,另一个是生成GIF的时候报错。 这是因为作者的示例是网络加载数据,会读取不到。通过读取本地文件,就不会出错。 GIF生成失败一般是需要安装imagemagick(图片处理工具)。 最近小F又发现一个可视化图库「Pandas_Alive」,不仅包含动态条形图,还可以绘制动态曲线图、气泡图、饼状图、地图等。 同样也是几行代码就能完成动态图表的绘制。 安装版本建议是0.2.3,matplotlib版本是3.2.1。 同时需自行安装tqdm(显示进度条)和descartes(绘制地图相关库)。 要不然会出现报错,估计是作者的requestment.txt没包含这两个库。 好了,成功安装后就可以引入这个第三方库,直接选择加载本地文件。 import pandas_aliveimport pandas as pdcovid_df = pd.read_csv('data/covid19.csv', index_col=0, parse_dates=[0])covid_df.plot_animated(filename='examples/example-barh

人工智能-语音合成-语音识别

拈花ヽ惹草 提交于 2020-12-06 05:26:50
图灵机器人: http://www.tuling123.com 百度开发平台: http://ai.baidu.com/ 下载 baidu-api 如果已安装pip,执行 pip install baidu-aip 即可。 ffmpeg 先下载文件,再配置到系统路径 下载完安装包,解压后,将该绝对路径 配置到系统路径。 配置成功如下: 打开电脑的录音机。 jieba中文分词 1. 2.创建应用 3.自动生成 4. 语音合成 1. 2.复制代码到一个新的py文件中。 3.右键运行,即可将文字转成语音。 代码: # 语言合成 文字 ->语音 from aip import AipSpeech """ 你的 APPID AK SK """ APP_ID = ' 11262331 ' API_KEY = ' Weu6QCLgU8oCPvULqpOSer7c ' SECRET_KEY = ' wMThGsaL8NPdNgE6z4A3Rmes1DvWNBO1 ' client = AipSpeech(APP_ID, API_KEY, SECRET_KEY) result = client.synthesis( ' 你好呀,我的贝贝 ' , ' zh ' , 1 , { ' vol ' : 5 , ' spd ' : 6 , ' pit ' : 3 , ' vol ' : 9 , ' per '

深入细枝末节,Python的字体反爬虫到底怎么一回事

被刻印的时光 ゝ 提交于 2020-12-06 04:58:24
内容选自 即将出版 的《Python3 反爬虫原理与绕过实战》,本次公开书稿范围为第 6 章——文本混淆反爬虫。本篇为第 6 章中的第 4 小节,其余小节将 逐步放送 。 字体反爬虫开篇概述 在 CSS3 之前,Web 开发者必须使用用户计算机上已有的字体。但是在 CSS3 时代,开发者可以使用@font-face 为网页指定字体,对用户计算机字体的依赖。开发者可将心仪的字体文件放在 Web 服务器上,并在 CSS 样式中使用它。用户使用浏览器访问 Web 应用时,对应的字体会被浏览器下载到用户的计算机上。 在学习浏览器和页面渲染的相关知识时,我们了解到 CSS 的作用是修饰 HTML ,所以在页面渲染的时候不会改变 HTML 文档内容。由于字体的加载和映射工作是由 CSS 完成的,所以即使我们借助 Splash、Selenium 和 Puppeteer 工具也无法获得对应的文字内容。字体反爬虫正是利用了这个特点,将自定义字体应用到网页中重要的数据上,使得爬虫程序无法获得正确的数据。 6.4.1 字体反爬虫示例 示例 7:字体反爬虫示例。 网址: http://www.porters.vip/confus... 。 任务:爬取影片信息展示页中的影片评分、评价人数和票房数据,页面内容如图 6-32 所示。 图 6-32 示例 7 页面 在编写代码之前,我们需要确定目标数据的元素定位

Why customer python package can not be imported?

☆樱花仙子☆ 提交于 2020-12-06 04:45:20
问题 I created my own python package named jjnsegutils and upload it to Pypi website. But after I successfully install it by pip install jjnsegutils , I still can not import it. Error shows: ModuleNotFoundError: No module named 'jjnsegutils' . Details about the whole procedure are as follows. Package structure and details The structure of my package is: jjnsequtils ├─ __init__.py ├─ myutil ├─ __init__.py ├─ myutil.py ├─ LICENSE ├─ README.md ├─ setup.py Two __init__.py files are empty. In my setup

Python --version does not update

邮差的信 提交于 2020-12-06 04:03:34
问题 I upgraded and installed latest Python version 3.8.1. Problem is, when I type python --version on terminal I get Python 2.7.16, when I type python3 --version I get Python 3.8.1. But if I try to pip install -U selenium I get a message: "DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at

Python --version does not update

笑着哭i 提交于 2020-12-06 04:00:22
问题 I upgraded and installed latest Python version 3.8.1. Problem is, when I type python --version on terminal I get Python 2.7.16, when I type python3 --version I get Python 3.8.1. But if I try to pip install -U selenium I get a message: "DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at

Tensorflow: docker image and -gpu suffix

為{幸葍}努か 提交于 2020-12-06 03:36:17
问题 In the Docker image for Tensorflow with GPU support (for example: tensorflow/tensorflow:2.2.0-gpu ) the installed python package is tensorflow-gpu (as shown in pip freeze ). Installing any python package that depends on tensorflow triggers the installation of tensorflow itself, although it's already installed under a different name (because -- correctly -- tensorflow-gpu != tensorflow ). Is there a way to avoid this? 回答1: You can add an instruction to install a fake tensorflow "package" that

Tensorflow: docker image and -gpu suffix

安稳与你 提交于 2020-12-06 03:36:12
问题 In the Docker image for Tensorflow with GPU support (for example: tensorflow/tensorflow:2.2.0-gpu ) the installed python package is tensorflow-gpu (as shown in pip freeze ). Installing any python package that depends on tensorflow triggers the installation of tensorflow itself, although it's already installed under a different name (because -- correctly -- tensorflow-gpu != tensorflow ). Is there a way to avoid this? 回答1: You can add an instruction to install a fake tensorflow "package" that

python -- DNS处理模块dnspython

核能气质少年 提交于 2020-12-06 03:15:21
简介 dnspython – 是python实现的一个DNS工具包,利用其查询功能来实现dns的服务监控及解析结果的校验 安装dnspython pip install dnspython 使用 常见的DNS解析类型包括A、MX、NS、CNAME (1)A记录的查询,实例如下: import dns.resolver domain = raw_input('Please input an domain: ') A = dns.resolver.query(domain, 'A') for i in A.response.answer: for j in i.items: print j.address 运行输入:www.baidu.com,输出结果如下: (2)MX记录 domain = raw_input('Please input an domain: ') MX = dns.resolver.query(domain, 'MX') for i in MX: print 'MX preference =', i.preference, 'mail exchanger =', i.exchange 运行输入:163.com,输出结果如下: (3)NS记录 print '*************NS****************' domain = raw_input(

Python开发:在mac系统中安装pip

不打扰是莪最后的温柔 提交于 2020-12-05 22:08:21
pip用来安装python项目的依赖库。 大多数比较新的python版本都自带pip,所以先检查下pip是否有安装。 终端输入:pip --version 如果没有安装pip,那么就用接下来的方式安装pip。 -- 前言 安装pip的方式是运行一个python文件,因此请先确保电脑中已经安装有python。 这个python文件的内容在互联网上有,放置在【 https://bootstrap.pypa.io/get-pip.py 】中。 因此首先需要将该python文件下载到本地电脑中。 方式一: 在浏览器中访问 https://bootstrap.pypa.io/get-pip.py 网址,如果出现对话框,选择保存文件;如果在浏览器中直接显示其中的代码内容,那么就等着页面内容加载完毕以后,将代码拷贝到文本编辑器中,文件类型定义为.py(比如:get-pip.py)。 方式二: curl https: // bootstrap.pypa.io/get-pip.py -o <#目标文件地址#> 注意:在运行上面的命令行之前,先创建一个以.py为后缀空文件(比如:get-pip.py),用该文件的地址替换上面命令行中的<#目标文件地址#> 下载完该python文件之后,在终端用python运行该文件就好了。 sudo python get-pip.py 或者是 sudo python3