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

  • 相关阅读:
    2022医药数据采集-整合超过10万个数据信息源
    30行代码做一个简易的抽奖系统(一)
    逆置链表(原地逆置链表)
    【Linux】线程
    Tomcat 源码解析一请求处理的整体过程-黄泉天怒(上)
    Jenkins+Maven+Gitlab+Tomcat 自动化构建打包、部署
    python用minimize() 函数替代matlab的fmincon函数
    Python入门教程 | Python 常用标准库概览
    mybatis plus generator 3.5.1 从了解到自定义定制VO、PO、DTO
    Go 1.21 新内置函数:min、max 和 clear
  • 原文地址:https://blog.csdn.net/weixin_45122104/article/details/126195181