• Python · Use Tsinghua And Douban Image Source To Download Python Packages


    Hello,everyone.I am Classmate Yu.
    Today,I will tell you how to download Python Packages From Tsinghua or Douban Image Source.

    Leading-in

    First,download Python from python.org,and choose your favourite version of Python.

    (Press the download button,then choose the version.You can download the amd64 installer,it is convenient.I prefer to use version 3.7.0,because it is stable)

    And then,install Python(No Pictures)

    And… If you see the sentence which said: “Install was successful.”
    Congratulations, you have successfully installed Python.
    Now,enjoy programming!

    Use Python Packages

    We use Python Packages very often,they included Tkinter,os,random etcetera.
    You should write like this if you want to use them:

    import tkinter
    import tkinter as tk
    from tkinter import messagebox
    from tkinter import *
    """
    import + Module Name
    import + Module Name + as + New Name
    from + Module Name + import + Function Name
    """
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    But sometimes we use an not installed package,the program will report an error.

    We always use pip to solve this problem,but in China,since the Python server is too far away,we had to wait a long time for it to be installed,it is too slow

    So,that is why in China we usually use Tsinghua or Douban mirror sources,it is very fast.
    I will tell you how to use them.

    Install Python Packages

    For example,I want to use Pygame,I must install Pygame first.

    pip install pygame
    
    • 1

    Download takes a long time…
    But it is also fast,because Pygame takes up very little memory.

    If you want to use Tensorflow,you will be amazed.

    Three Hours! That is a long time.

    Then,here comes the problem,how to make it faster?
    Easy.

    You can run the following command in Windows Terminal:

    pip install tensorflow -i https://pypi.doubanio.com/simple
    
    • 1


    It is much faster!
    You can also use other mirror sources,down here:

    pip install ModuleName -i https://pypi.doubanio.com/simple #Douban Image Source
    pip install ModuleName -i https://pypi.tuna.tsinghua.edu.cn/simple #Tsinghua Image Source
    pip install ModuleName -i https://mirrors.aliyun.com/pypi/simple #AliBaba Image Source
    
    • 1
    • 2
    • 3

    If you want to use a mirror source in the future,you can write like this:

    pip config set global.index-url https://pypi.doubanio.com/simple
    
    • 1

    Cancel Settings:

    pip config unset global.index-url
    
    • 1

    OK,That’s all for this episode.
    If you like my blog, don’t forget to “Like” !
    Bye!

  • 相关阅读:
    ArkUI-X+HarmonyOS Next跨平台App开发
    C++每日面经
    java计算机毕业设计基于ssm的高校普法系统(源代码+数据库+Lw文档)
    2022 ICPC Gran Premio de Mexico 1ra Fecha(一)
    【理论知识:Window Aggregation】flink 窗口聚合功能概述:两种窗口聚合模式的使用例子、功能说明
    haproxy
    通达信历史期货数据接口源代码是怎样的?
    IDEA代码重构技巧--抽取类和接口
    mysql高阶语句(一)
    7-69 猴子选大王
  • 原文地址:https://blog.csdn.net/weixin_45122104/article/details/126195181