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
"""

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

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


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

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

Cancel Settings:

pip config unset global.index-url

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

猜你喜欢

转载自blog.csdn.net/weixin_45122104/article/details/126195181