1

I'm a relatively new python user and I'm consistently running into this (perhaps simple?) problem and its really getting in the way of me making any advancement.

Here's the problem. Whenever I try to install a package, using either pip or easy_install, I get errors saying that my user profile doesnt have access to the installation directory. I am the admin of my computer, however. The installation never completes using easy_install (i get the error below), but it eventually finishes using pip, but I cant import the package after the instalation--I get the usual "no module named [module name]" error.

Easy_install error message:
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/test-easy-install-3280.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  http://packages.python.org/distribute/easy_install.html

Please make the appropriate changes for your system and try again.
Kara
  • 6,115
  • 16
  • 50
  • 57
Merv Merzoug
  • 1,149
  • 2
  • 19
  • 33
  • Looks like my site-packages folder is empty in the python 2.7 folder. Is that where the installed packages are supposed to be? I have tried moving on of the modules' folders to this location, restarting python to see if that has any effect, but nothing. – Merv Merzoug Jan 14 '14 at 16:02

2 Answers2

1

A simpler possibility, compared to virtualenv is installing the package in the home directory by typing:

easy_install --user <package> 

Your package will be installed in ~/.local/lib/python2.7, which is in the default path for python packages.

This works platform independent. From your output I guess you are using Linux. On Windows, easy_install always requires admin rights if you are using a standard Python installation.

oekopez
  • 1,080
  • 1
  • 11
  • 19
0

You'll need to use sudo, as you're trying to install in the global packages folder (/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/), and your user apparently doesn't have write permission for that folder.

While sudo will help you past that restriction, have a look at virtualenv to create separate, independent environments where you can install different packages without the overlap. Also, the Python that comes with OS X is apparently a modified version, so you might be better off installing a complete, independent version. That way, you won't be affected if Apple ever upgrades the Python release (or doesn't, and you need a different version).

I found this article rather good in getting me up and running with Python on OS X.

DocZerø
  • 8,037
  • 11
  • 38
  • 66
  • `sudo easy_install` is generally a bad idea, since easy_install makes no attempt whatsoever to be secure. – Wooble Jan 14 '14 at 12:48
  • Thanks Kristof, I followed the directions step by step in the article including updating my OS to mavericks, but it appears that the problem has just been magnified. Whenever I try to import packages I know are installed (numpy, scipy, matplotlib) python crashes. I'm able to import these packages in ipython, but not in python itself. Any idea what is going on? – Merv Merzoug Jan 14 '14 at 15:34
  • First, check if you're using the correct python by running `which python`. Also, have a look at the shebang to see if that point to the right python location as well. Check [this](http://stackoverflow.com/questions/20952797/pip-installing-in-global-site-packages-instead-of-virtualenv) question (and the answer) for more info. – DocZerø Jan 14 '14 at 17:02