亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我不知道如何處理消失的 python 模塊

我不知道如何處理消失的 python 模塊

拉丁的傳說 2023-06-20 15:51:17
是的,您沒有看錯,我一直在使用 Python CrashCourse 中的 matplotlib 進行練習。在我的項目目錄中處理一個新文件時,當我嘗試運行該文件時,它給我標記了一個錯誤。它告訴我模塊 matplotlib 不存在,即使我已經使用它一個月了。我試圖在與 matplotlib 相同的目錄中運行我的舊文件,但我不能,它告訴我它不存在,這很奇怪。我花了一整天的時間一遍又一遍地安裝它,我檢查了我是否為我的電腦使用了正確的版本。當我在終端上測試它時我沒有任何問題,它告訴我它已經安裝但是每次嘗試在我工作的目錄或任何其他目錄中的 VisualStudio 中運行文件時它告訴我該模塊沒有存在。這是我的代碼import csvfrom matplotlib import pyplot as pltfilename = '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 win32Type "help", "copyright", "credits" or "license" for more information.>>> import matplotlib>>> ```It shows no error.   [1]: https://i.stack.imgur.com/G9JXC.png
查看完整描述

1 回答

?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

您不小心在可視代碼中切換了 python 版本。要解決此問題,您必須轉到右下角顯示 python 版本的位置,然后單擊它進行更改。

http://img1.sycdn.imooc.com//64915aa70001c42d02470226.jpg

如果你想下載另一個版本的 matplotlib,你必須這樣做:

pip(python version) install matplotlib

前任:

pip3.7 install matplotlib


查看完整回答
反對 回復 2023-06-20
  • 1 回答
  • 0 關注
  • 135 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號