我是 python 的新手,并試圖從現有專案中運行代碼。我收到以下錯誤:
Traceback (most recent call last):
File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py", line 2, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'
該檔案存在于上述路徑中。我看到有很多關于此的問題,但似乎沒有什么可以為我提供解決方案。我正在使用 IntelliJ IDEA IDE。
uj5u.com熱心網友回復:
錯誤訊息告訴您File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py"正在嘗試匯入pytest但找不到包。也就是說,失敗的不是該檔案的存在,而是它無法找到pytest以匯入它。
安裝pytest使用
python3 -m pip install pytest
python3相應地更改以使用您在 IDE 中使用的特定 python 安裝。
uj5u.com熱心網友回復:
這是因為您沒有所需的環境。既然你用的是Pycharm,你可以嘗試安裝pytest。 https://blog.finxter.com/how-to-install-a-library-on-pycharm/
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/368614.html
