• 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!

  • 相关阅读:
    Typora打造最适合编程笔记的精美主题(浅色版和修改后的深色版),可自行修改喜欢的样式。
    基于工业智能网关的汽车充电桩安全监测方案
    自定义类加载器
    【uniapp】短信验证码输入框
    不到2000字,轻松带你搞懂STM32中GPIO的8种工作模式
    盲盒商城源码 盲盒开箱源码 潮物盲盒商城源码 仿CSGO盲盒开箱源码
    JS正则表达式
    mysql、sqlserver数据库之间的数据同步
    20231114在HP笔记本的ubuntu20.04系统下向RealmeQ手机发送PDF文件
    牛客小白月赛#59(A~F)
  • 原文地址:https://blog.csdn.net/weixin_45122104/article/details/126195181