栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【Python 学习技能篇】安装三方库方法和问题总结

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Python 学习技能篇】安装三方库方法和问题总结

今天,稍微整理一下,最近学习python过程中遇到的几个问题,并整理几个常用命令。

一、工具 pip 相关

命令:查看 pip 版本

pip -V

命令:升级 pip 版本

python -m pip install --upgrade pip

二、安装第三方模块

实际开发中,我们十分有必要去下载和安装第三方的模块库。

第三方模块的资源链接:

清华大学镜像
https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云
http://mirrors.aliyun.com/pypi/simple/
中科大镜像
https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣镜像
http://pypi.douban.com/simple/
中科大镜像2
http://pypi.mirrors.ustc.edu.cn

# 临时使用
pip3 install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install numpy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install pandas -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install seaborn scipy  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

# 永久使用
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

如果需要全局修改,则需要修改配置文件。
Linux/Mac os 环境中,配置文件在 ~/.pip/pip.conf(如不存在创建该目录和文件):
mkdir ~/.pip
打开配置文件 ~/.pip/pip.conf,修改如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
查看镜像地址:
$ pip3 config list   
global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'
install.trusted-host='https://pypi.tuna.tsinghua.edu.cn'
可以看到已经成功修改了镜像。

Windows下,需要在当前对用户目录下(C:Usersxxpip,xx 表示当前使用用户)创建一个 pip.ini在pip.ini文件中输入以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
三、具体问题

本人,因为无聊,学学python 这门神奇的语言。也就是骨灰级小白开始。B站上面讲述python 的资料太多了,没心思去看完,所以遇到了很多问题。

问题1:安装email 邮件包 遇到安装失败

然后,百度问了下度娘,有人建议升级一下 pip install --upgrade setuptools

不过实际操作了之后,还是报错。

手残,在代码中添加了 import email 行,不报错,肯定说明已经安装了 email 模块。到底是sublime , 还是 哪个模块携带了email 模块,不得知,也没去研究,问题解决了就好么。

问题2 : 安装json时报错

C:UsersAdministrator>pip install json

ERROR: Could not find a version that satisfies the requirement json (from versions: none)

ERROR: No matching distribution found for json

#是已经安装了吗?还是内置的?。。。

问题3:使用 pip search 命令搜索

使用 pip  search 命令进行 相应的安装库的时候,搜索失败。

比如: pip search urllib

Python官方的事故调查记录 PyPI XMLRPC 搜索已禁用 更新- 我们现在距离禁用 XMLRPC 搜索端点的决定已过去 100 天。

到端点的流量没有以任何实质性的方式消退,我们也没有收到任何一方继续每小时发出数十万次搜索呼叫的消息。因此,将永久禁用 XMLRPC 搜索。

解决方法:安装第三方库 pip-search , 来代替 pip  seartch 

pip install pip-search

然后输入: pip_search urllib

(待续。。。)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/925606.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号