Windows installation matplotlib method (cmd+pycharm) + cmd does not run python command solution

foreword

  I am learning matplotlib recently, but I encountered problems when installing it. I write an article to record it and hope it can help more people.


Table of contents

foreword

1. Install matplotlib via cmd

1. Install python

2. Install pip

3. Install matplotlib

Two install matplotlib through pycharm

Three cmd does not run the python command solution


1. Install matplotlib via cmd

1. Install python

First you need to make sure that python and pip are installed on your system.

The installation of python is in the official download compressed package, just install it. You can search for related articles for installation. It is recommended that the version of python should be higher.

2. Install pip

First check whether pip has been installed on the computer, open win+r, enter cmd, and enter the following code to view the pip version.

python -m pip --version

My pip is already installed, so that's what it looks like.

 

Here's how to install pip:

Put the get-pip.py file in the python directory, open cmd and enter the corresponding directory to run get-pip.py

py get-pip.py

Put a get-pip link.

Link: https://pan.baidu.com/s/1z1Xn4N39BtDUJcWtgO9U6A 
Extraction code: kv2j

Then when it was installed, it reported red again! The error is shown in the figure below

The solution is to use Tsinghua's mirror to download.

code show as below: 

py get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple/

Then enter the code to view the pip version, showing that pip has been successfully installed.

3. Install matplotlib

 Next, it is time to enter the command in cmd to install matplotlib.

code show as below:

pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple/ 

After the installation is successful, enter the python mode, enter the matplotlib drawing code, and wait for a few seconds to automatically pop up the drawing picture.

python
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.show()

 Two install matplotlib through pycharm

pycharm installs matplotlib similar to cmd.

Create a py file and write the drawing code. If it is not installed, it will prompt no module named matplotlib.

At this time, open the terminal and enter the same code that cmd installed matplotlib before.

 

 code show as below:

pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple/ 

The result is shown in the figure below.

 

The advantage of pycharm is that there will be prompts, and writing code is faster.

Three cmd does not run the python command solution

  When I first entered the python command with cmd, the new command was returned directly, and there was no response to python. After various tests, it was found that it might be a python version problem. It was version 3.6 before, and then I downloaded version 3.10, and the installation went smoothly. Sure enough, after the installation is complete, you can continue to use cmd to run python commands~

Guess you like

Origin blog.csdn.net/qq_43604183/article/details/126064767