[英]How can I install pygame to my vs code project in OSX?
我想將 pygame 包添加到我的 vs 代碼項目中。 我使用的是 OSX,我安裝了 pip、python 並下載了 pygame。
但我無法安裝它。 我閱讀了我的控制台日志,但我不知道如何修復它:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pygame
Using cached https://files.pythonhosted.org/packages/96/e6/a0e790157db7dc6b62192d09a93085bcb2a5261ee45ddc4d6d225ecc4a4d/pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl
Saved ./pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl
Successfully downloaded pygame
choehyomin-ui-MacBookPro:~ choihyomin$ pip install pygame
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pygame
Using cached https://files.pythonhosted.org/packages/96/e6/a0e790157db7dc6b62192d09a93085bcb2a5261ee45ddc4d6d225ecc4a4d/pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl
Installing collected packages: pygame
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pygame'
Consider using the `--user` option or check the permissions.
最好的解決方案是創建一個虛擬環境,以便您可以安裝到其中而不是全局 Python 安裝中。 但如果這不是一個選項,那么錯誤消息中的建議是有道理的:使用--user
:
pip install --user pygame
但是請確保為您在 VS Code 中選擇的 Python 解釋器安裝了pip
,而不是其他已安裝的 Python 副本。 如果不確定,最安全的方法是指定要為其安裝的 Python 解釋器:
/path/to/python -m pip install --user pygame
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.