我不知道';I don’我不知道该如何处理一个已发布的python模块

我不知道';I don’我不知道该如何处理一个已发布的python模块,python,matplotlib,Python,Matplotlib,是的,你读对了,我一直在用Python CrashCourse的matplotlib做练习。在我的项目目录中处理新文件时,当我尝试运行该文件时,它将我标记为错误。它告诉我matplotlib模块不存在,尽管我已经使用了一个月。我试着用matplotlib在同一个目录下运行我的旧文件,但我做不到,它告诉我它不存在,这很奇怪。我花了一整天的时间一遍又一遍地安装它,我检查了我的电脑是否使用了正确的版本。当我在终端上测试它时,我没有任何问题,它告诉我它已经安装好了,但每次尝试在我工作的目录或任何其他目录

是的,你读对了,我一直在用Python CrashCourse的matplotlib做练习。在我的项目目录中处理新文件时,当我尝试运行该文件时,它将我标记为错误。它告诉我matplotlib模块不存在,尽管我已经使用了一个月。我试着用matplotlib在同一个目录下运行我的旧文件,但我做不到,它告诉我它不存在,这很奇怪。我花了一整天的时间一遍又一遍地安装它,我检查了我的电脑是否使用了正确的版本。当我在终端上测试它时,我没有任何问题,它告诉我它已经安装好了,但每次尝试在我工作的目录或任何其他目录下的VisualStudio中运行文件时,它都会告诉我该模块不存在

这是我的密码

import csv
from matplotlib import pyplot as plt



filename = 'sitka_weather_07-2014.csv'
with open(filename) as f:
    reader = csv.reader(f)
    #We save the first line  using a csv function
    header_row = next(reader)
    
    '''#We use enumerate() to put an index on each value
    for index, column_header in enumerate(header_row):
        print(index, column_header)'''
    #We get the high temperatures    
    highs = []
    for row in reader: #We continue in the second line
        highs.append(int(row[1]))
    #print(highs)
    #Plot data
    fig = plt.figure(dpi=128, figsize=(10,6))
    plt.plot(highs, c='red')

    #Format plot
    plt.title("Daily high temperatures, July 2014", fontsize=24)
    plt.xlabel('', fontsize=16)
    plt.ylabel('Temperature (F)', fontsize=16)
    plt.tick_param(axis='both', which='major', labelsize=16)

    plt.show() 
[![在此处输入图像描述][1][1]

我试过打字

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> ```

It shows no error. 


  [1]: https://i.stack.imgur.com/G9JXC.png

您不小心在可视代码中切换了python版本。 要解决这个问题,您必须转到右下角的python版本,然后单击它进行更改

如果要在其他版本中下载matplotlib,必须执行以下操作:

pip(python版本)安装matplotlib
例:

pip3.7安装matplotlib

在python idle中尝试一下,看看是否有效。如果我使用了3.7.1,我将使用3.7.1。如何辨别或切换回?在显示3.7.5的图片中,请查看左下角。如果单击它,可以更改版本。无论安装matplotlib的版本是什么,都需要切换到自己的版本。如果您不知道可以再次安装:do pip[python版本]安装matplotlib示例:pip3.8安装matplotlib非常感谢您:我把它换成了3.7.1,现在它又能工作了。不知道我什么时候换的,但是谢谢,谢谢,谢谢!