Python安装第三方库

背景

法1:直接将现有的库文件移至python/Lib文件夹下,有虚拟环境则是anaconda/envs/xxx/Lib, xxx是你创建的虚拟环境名字。下图中flower是我自己创建虚拟环境名,具体得看用户自己创建的。

示例图

法2:用命令,在想要的环境下cmd,输pip install xxx,xxx是库名.带版本的话,pip install xxx==1.1.0,1.1.0看具体版本。

若下载慢用镜像,此时若需下载库多,则配置镜像;

# pip版本
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# conda版本
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
# 解决下载慢
conda config --set channel_priority flexible

若少,则直接命令,其中xxx是库名

pip install -i http://pypi.tuna.tsinghua.edu.cn/simple xxx

 

法3:.whl文件pip 方式在CMD->cd命令下进入到.whl文件所在目录,cmd后

pip install xxx.whl。

补充下载地址:

 

发表评论