如何導入python模組?

如何導入python模組?

我想安裝一個允許我使用測量單位的庫(例如:流明等)。我在電腦上安裝了一個套件(透過cmd),我在環境設定中看到的套件在Visual Studio中工作,但我無法將其匯入專案並使用它。我添加了一個螢幕截圖來說明。

在此輸入影像描述

答案1

正如您自己的螢幕截圖(左下角)所示,您的安裝python-units似乎失敗了:

ERROR: Could not find a version that satisfies the requirement python-units==0.1.2 (from version: none)

另外:

ERROR: No matching distribution found for python-units==0.1.2

注意到您似乎正在使用 Python 3.7(再次,從您的螢幕截圖來看)並檢查PyPI 上 python 單元的檔案下載頁面,我們可以看到僅支援 Python 2.x(如唯一可用的.whl檔案名稱所示):

python_units-0.1.2-py2-none-any.whl

相關內容