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

  • 相关阅读:
    IDEA设置注释快捷键进行 注释对齐
    Linux CentOS7 系统中添加用户
    房地产中介信息管理系统平台源码开发解决方案
    docker安装ftp服务器
    如何成功安装Node.js并在VS Code终端使用npm
    【手写一个Tomcat】SimpleTomcat-01
    CDN:加速型与高防型的不同
    基于Golang语言GoFrame+Vue+ElementUI后台管理系统框架
    【工具篇】Unity翻书效果插件Book-Page Curl Pro教程
    Docker数据持久化与数据共享
  • 原文地址:https://blog.csdn.net/weixin_45122104/article/details/126195181