0

I'm trying to install Pelican for python using pip install pelican, but I get these errors. I use Python 2.7.9 bundled with Mac OSX

Exception:
    Traceback (most recent call last):
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg    >/pip/basecommand.py", line 211, in main
        status = self.run(options, args)
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg
/pip/commands    /install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req
/req_set.py", line 646, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req
/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req
/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", 
line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", >line 310, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils
/__init__.py", line 71, 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/pelican'
Evens-MacBook-Pro:~ even$ 
falsetru
  • 357,413
  • 63
  • 732
  • 636
Even T
  • 31
  • 3
  • Possible duplicate of [error: could not create '/Library/Python/2.7/site-packages/xlrd': Permission denied](http://stackoverflow.com/questions/18199853/error-could-not-create-library-python-2-7-site-packages-xlrd-permission-den) – pherris Jan 08 '16 at 15:57

3 Answers3

2

Your normal user cannot install to the system-wide Python package directory. Instead of using sudo, install the package locally for your user account:

pip install --user pelican
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
0

That error occured because you don't have permission to write on that system directory. Hence the OSError: [Errno 13] Permission denied.

If you want to install it system wide, you have to run pip with superuser rights in order to gain permission:

sudo pip install pelican

Although, that wouldn't be necessary -- nor a good practice --, for instance, if you are installing inside a virtualenv.

Another possibility, as referred in this answer pointed out by @pherris, is to append the --user flag to the pip command. This would install the package only to the current user:

pip install pelican --user
Community
  • 1
  • 1
iled
  • 2,142
  • 3
  • 31
  • 43
  • 1
    Thank you! I ended up doing the virtualenv – Even T Dec 12 '15 at 17:11
  • @EvenT I'm glad it helped. Please take the time to accept one of the answers. – iled Dec 12 '15 at 18:03
  • `sudo` isn't the solution for installing TPS. This can be fixed in other ways: stackoverflow.com/a/23789994/1861459 – pherris Jan 08 '16 at 15:56
  • @pherris You are right, but I think the downvote was not necessary: I explained the error message and offered a solution (actually, two solutions). We don't know if the OP wanted to install system wide or just for the specific user. More than that -- and continuing to do assumptions about OP's intentions --, installing in a virtualenv could be an even better approach for development purposes than using the `--user` flag; even if it is not, I second that it is better than using `sudo`, hence the suggestion. – iled Jan 08 '16 at 16:20
  • I'm feel frustrated about having to `sudo` to get anything working in python - if you make an edit to the post I can un-down vote with the clarification. – pherris Jan 08 '16 at 18:00
  • @pherris Thanks for your comments. I have improved my answer accordingly. – iled Jan 08 '16 at 18:57
-1

Modifying the system-level installation of Python (or Ruby, or Perl...) can turn into a mess, and I have had my work there trashed in the past by system updates. Apple doesn't really guarantee your local changes will be preserved after an OS update.

You are likely better off installing your own versions using something like Homebrew, which installs into /usr/local.

Homebrew has Python 2.x and 3.x available (and they can co-exist very well). It keeps up with new releases better than Apple does. Homebrew also has many other Unix things that you may or may not find useful.

After installing Homebrew, installing Python is simple:

brew install python
brew install python3

Make sure /usr/local/bin is early in your $PATH. It also provides you with pip and pip3 to install Python package for both 2.x and 3.x.

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
  • `sudo` is not the solution when something won't install. You're effectively saying "hey, let this program do whatever it wants." Since the OP probably didn't write `pip`, they should not feel comfortable installing it (or any TPS) with `sudo`. http://stackoverflow.com/a/23789994/1861459 – pherris Jan 08 '16 at 15:54
  • @pherris which is why I suggested using brew instead... :) – Dan Lowe Jan 08 '16 at 16:15
  • I'm feel frustrated about having to `sudo` to get anything working in python - if you make an edit to the post I can un-down vote with the clarification. – pherris Jan 08 '16 at 18:00
  • @pherris Thinking about this again, you are right. Better to not mention sudo, and just direct people to use homebrew instead. I have had Apple OS updates trash my changes in `/Library` in the past, too. – Dan Lowe Jan 09 '16 at 01:19