pip使用总结(持续更新)

        持续总结python pip遇到过的坑。

1、pip镜像源

#阿里镜像-临时
pip install xxx -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

#豆瓣镜像-临时
pip install xxx -i https://pypi.douban.com/simple/

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

2、conda镜像源

        首先输入:

conda config --set show_channel_urls yes

        在~/.condarc文件输入如下内容(vi ~/.condarc)

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

        如果需要移除镜像源,直接输入:

conda config --remove channels

3、安装pycrypto

        Python3中安装pycrypto错误的最简解决方案,不用安装xG的C编译器,直接用下面命令安装:

pip install pycryptodome

Python3中安装pycrypto错误的最简解决方案,不用安装xG的C编译器_hirbale的博客-CSDN博客

4、 cl.exe failed

        pip 安装模块时 cl.exe failed 可能的解决办法

pip 安装模块时 cl.exe failed 可能的解决办法 - 哔哩哔哩

5、安装到指定目录

pip install xxx -t dest_dir

6、 pip install安装错误

        pip install安装时可能出现如下错误:

UnicodeDecodeError: 'gbk' codec can't decode byte 0x98 in position 1027: illegal multibyte sequence

解决方法:找到python安装目录下的Lib\configparser.py文件,将其中的第695行进行如下更改:

with open(filename, encoding=encoding) as fp:
    self._read(fp, filename)
#改为:
with open(filename, encoding='utf-8') as fp:
    self._read(fp, filename)

7、windows pip install 错误

        ERROR: Could not build wheels for argon2-cffi which use PEP 517 and cannot be installed directly
         fatal error C1083: 无法打开包括文件: “io.h”: No such file or directory

        出现这些问题,很有可能是pip自身环境出错了,建议卸载并重新安装pip。

(1)卸载pip:python -m pip uninstall pip
(2)cmd输入:py -m ensurepip --upgrade
(3)get-pip.py下载:https://download.csdn.net/download/suiyingy/85506671或https://bootstrap.pypa.io/get-pip.py
(4)cmd输入:py get-pip.py

8 pip卸载包错误

        ERROR: Cannot uninstall [pacakage]. It is a distutils installed project…
        解决方案:先使用pip install --ignore-installed [package]后再卸载或者重装

9 待补充

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Coding的叶子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值