安裝numpy包
1、找到對應python版本的numpy包的版本
- NumPy - News確認適配python版本的numpy,我安裝 的python是3.11所以安裝的numpy是2.2.0
2、修改pip安裝的鏡像源
1、全局修改:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
2、臨時使用鏡像源:在安裝包名的后面使用 -i 鏡像源地址
pip install some-package -i https://pypi.tuna.tsinghua.edu.cn/simple
3、修改
pip.ini
(或pip.conf
)配置文件,并配置環境變量%HOMEPATH%\pip\pip.ini,添加或者修改內容如下:[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
常用的鏡像源列表:
-
清華大學開源軟件鏡像站:?
https://pypi.tuna.tsinghua.edu.cn/simple
-
中國科技大學開源軟件鏡像站:?
https://pypi.mirrors.ustc.edu.cn/simple/
-
阿里云開源鏡像站:?
https://mirrors.aliyun.com/pypi/simple/
-
豆瓣開源鏡像站:?
https://pypi.doubanio.com/simple/
3、修改pycharm的Python解釋器環境配置
PyCharm默認使用項目虛擬環境解釋器(路徑包含.venv
),如果將numpy安裝到系統的python環境,就需要更改解釋器
解決辦法:
- 在PyCharm中打開設置(Windows/Linux:
File > Settings
;macOS:PyCharm > Preferences
)。 - 選擇
Project: [項目名] > Python Interpreter
- 確認當前解釋器路徑是否與安裝numpy的環境一致(可通過終端執行
pip show numpy
驗證安裝路徑)