-1

I want to add pygame package to my vs code project. I'm using OSX and I installed pip, python and downloaded pygame.

But I can't install it. I read my console log but I don't know how to fix it:

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.
Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
최효민
  • 11
  • 1
  • Permission denied. try `sudo pip` instead of `pip` – Blorgbeard Jun 28 '19 at 15:39
  • ERROR: Could not install packages due to an EnvironmentError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pygame' – 최효민 Jun 28 '19 at 16:37
  • still not working – 최효민 Jun 28 '19 at 16:37
  • 1
    Possible duplicate of [pip install -r: OSError: \[Errno 13\] Permission denied](https://stackoverflow.com/questions/31512422/pip-install-r-oserror-errno-13-permission-denied) – phd Jun 28 '19 at 17:07
  • https://stackoverflow.com/search?q=%5Bpip%5D+Errno+13+Permission+denied – phd Jun 28 '19 at 17:07
  • 1
    @Blorgbeard Please don't suggest using "sudo pip" -> https://stackoverflow.com/q/21055859/1931274 – pradyunsg Jun 29 '19 at 08:31

1 Answers1

0

The best solution is to create a virtual environment so that you can install into that instead of your global Python installation. But if that's not an option, then the suggestion in the error message makes sense: use --user:

pip install --user pygame

But do make sure that pip installs for the Python interpreter you have selected in VS Code and not some other installed copy of Python. If you're not sure, the safest way is to specify the Python interpreter you want to install for:

/path/to/python -m pip install --user pygame
Brett Cannon
  • 14,438
  • 3
  • 45
  • 40