python中package安装常用指令
一、安装位置:
(1)Pycharm中的mainmanu-settings-interpreter中安装。
(2)Pycharm中的terminal内输入指令安装
二、安装指令
(1)pip install 模块名字
(2)如果因为网络问题安装不了,用下面的命令行:
pip install 模块名 -i http://pypi.douban.com/simple
国内几个pip源网址如下:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里:http://mirrors.aliyun.com/pypi/simple/
豆瓣:http://pypi.douban.com/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/
三、特定库安装故障
(1)之前安装tensorflow库的时候,报错:
ERROR: Could not find a version that satisfies the requirement transformers (from versions: none) ERROR: No matching distribution found for transformers
(2)安装matplotlib时报错:
ImportError: DLL load failed: 找不到指定的模块。
最后的解决办法:
指定镜像源:pip install docxtemplater -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
上述语句指定了镜像源为阿里,使用--trusted-host
选项是为了确保与阿里云镜像的连接可以信任。