簡體   English   中英

numpy 已經安裝在我的筆記本電腦中,但是當我導入 numpy 模塊時,python 出現錯誤

[英]numpy is already installed in my laptop,but python gives error while i'm importing numpy module

我面臨以下錯誤:

import numpy
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import numpy
  File "C:\Users\saikr\Python38\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\saikr\Python38\lib\site-packages\numpy\_distributor_init.py", line 22, in <module>
    for filename in glob.glob(os.path.join(libs_dir,
AttributeError: module 'glob' has no attribute 'glob'

此錯誤發生在 IDE 中

C:\\Users\\saikr>numpy

'numpy' is not recognized as an internal or external command,
operable program or batch file.

這個錯誤發生在cmd

如何解決?

試試這個:: 在 cmd 中輸入python然后輸入import numpy as np

您的 IDE 很可能為您啟動的每個新項目創建一個Virtual Env (鏈接到 pep 405 以獲取有關 venv 的更多詳細信息)。 您可以在 IDE 中使用pip freeze來查看當前環境中所有已安裝的軟件包

發生第二個錯誤是因為您正在從 cmd 調用 python 命令。 您需要在代碼之前調用python命令才能從 cmd 運行 python 命令

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM