0

I tried to install pygame on my macbook pro by entering pip install pygame into the terminal. It didn't work and it just gave me:

Collecting pygame
  Using cached pygame-1.9.3-cp27-cp27m-macosx_10_9_intel.whl
Installing collected packages: pygame
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pygame'

I'm kinda new to programming and using the terminal for things so I might have made a huge stupid mistake but if you know what I did wrong or what I have to do to fix it please tell me.

Ivan
  • 34,531
  • 8
  • 55
  • 100
Jonathan Haar
  • 71
  • 1
  • 5

2 Answers2

0

I think you are running the command as a user that does not have permission to write to the system folders containing the Python base. Not sure on a Mac how you run a sudo command.

0

Use sudo pip install pygame to install. The last line of the error says permission denied, meaning you don't have permission as the current user. Sudo will temporarily make you root.

Nick H
  • 1,081
  • 8
  • 13
  • Also, often on a Mac you may get the error, that `sudo command not found` if so, do `export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH` then retry the command. – Nick H Mar 20 '17 at 20:51
  • When I do `sudo pip install pygame` it gives me the following: The directory '/Users/Jonathan/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/Jonathan/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. – Jonathan Haar Mar 22 '17 at 10:14
  • Ok, so to fix this type the command `sudo -H pip install pygame`. This means that sudo isn't pointing to the root directory. This problem is better documented here: http://stackoverflow.com/questions/27870003/pip-install-please-check-the-permissions-and-owner-of-that-directory – Nick H Mar 22 '17 at 10:53