pip 安装库出现以下问题,求解决!

初学编程,python安装库的时候总是失败,不知道该怎么解决。求各位解决

img

如果你还没有解决的话。建议参考下这个链接:https://github.com/pypa/pip/issues/5309#issuecomment-383440367

换个源看看
用户目录下建立个pip文件夹。
C:\Users\用户名\pip
文件夹里新建pip.ini文件。填上内容

[global]
timeout = 6000
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host=pypi.tuna.tsinghua.edu.cn

【相关推荐】



  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/7633557
  • 这篇博客也不错, 你可以看下完美解决python安装的pip命令无法使用问题。
  • 你还可以看下python参考手册中的 python- 使用pip管理包
  • 您还可以看一下 于成令老师的Python零基础入门教程课程中的 pip的使用小节, 巩固相关知识点
  • 除此之外, 这篇博客: 知道你的Python程序每一行运行消耗多少内存,需要多少时间吗?提高python运行效率!中的 一、每一行消耗了多少时间? 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:

    借助 line_profiler 模块
    具体代码如下

    from line_profiler import LineProfiler
    def func_line_time(follow=[]):
        def decorate(func):
            @wraps(func)
            def profiled_func(*args, **kwargs):
                try:
                    profiler = LineProfiler()
                    profiler.add_function(func)
                    for f in follow:
                        profiler.add_function(f)
                    profiler.enable_by_count()
                    return func(*args, **kwargs)
                finally:
                    profiler.print_stats()
    
            return profiled_func
    
        return decorate
    

    add_function 增加每列的行数
    最终要对enable_by_count进行执行才能获取消耗的时间
    print_stats 显示结果。

    使用的时候只需要将func_line_time 装饰函数即可。

    @func_line_time()
    def process(self, params):
        import pandas as pd
        import jieba
        pass
    

    运行结果

    在这里插入图片描述
    Hit:代码运行次数;
    %Time:代码占了它所在函数的消耗的时间百分比,通常直接看这一列。

    可以看到import jieba这个模块在这次运行中所占用的时间为22.8%,其他行数的百分比则不详细说了。
    在这里我们主要观察Time 所占用的百分比,对百分比较高的行数进行优化为第一选择。

    通过行 消耗时间的分析可以第一时间定位到比较耗时的行数,针对性的进行优化。提高运行效率。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^