1

I am learning python with no programming experience, from a textbook. It asked me to install setup tools, which I downloaded. However, whenever I try to install it through terminal as the website says, I get the following 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/2.5/lib/python2.5/site-packages/test-easy-install-2960.write-test'

I think I am doing something wrong on my part however I don't know what I'm doing wrong. I am running python 2.5, and i have downloaded setuptools 2.5 (the textbook asked for these specific versions).I have only gotten as far as downloading the setup tools file to my desktop. Can somebody please provide extremely thorough and easy instructions about how to install setup tools? I am running Mac OS X Mountain Lion.

4

2 回答 2

2

首先,Mountain Lion 附带的 Python 2.5、2.6 和 2.7 版本已经具有 setuptools 和/或分发,因此您无需在此处执行任何操作。但是,您稍后将再次遇到相同的问题,因此:

如果您想将任何东西安装到系统范围的站点包中,则需要使用它sudo来执行此操作,否则您没有写入权限。例如:

sudo python2.5 setup.py install

我也很好奇你为什么使用python2.5而不是python2.7(或只是python,这是同一件事)。没有多少库和程序可以与 2.5 一起使用,但不能与 2.7 一起使用,除非您特别需要其中一个程序,否则您应该坚持使用 2.7。(如果您遵循此建议,则可以在后面的所有内容中删除2.5-2.5后缀。)

同时,所有三个版本的 Python 都easy_install已经配置好了,因此您很少需要下载并手动安装;你可以这样做sudo easy_install-2.5 foo。但是,它pip甚至比. 所以,你应该做的第一件事是:easy_installpip

sudo easy_install-2.5 pip

foo然后,每当您将来需要安装软件包时:

sudo pip-2.5 install foo

许多人急于建议安装其他版本的 Python——Homebrew、MacPorts、Python.org、Enthought 或 ActiveState。不要这样做。在 Tiger(10.4)时代,这通常是必要的,因为 Apple 曾经发布不完整或损坏的 Python 版本,但很长一段时间以来都不是这样。这意味着您最终将得到两个python2.7/副本python,两个 / 副本easy_install-2.7easy_install最糟糕的是,一个pip-2.7/副本pip(无论您以后安装哪个副本都会删除旧的副本)。我保证你不会直截了当,你会带着新的问题回到这里,关于“我安装了包 foo 并且它成功了,但是现在我不能导入它”。

但是,如果你想要 Python 3,那么我肯定会推荐从 Homebrew 或 Python.org安装它。没有 Apple 安装的 3.x 版本,Python 2.x 和 3.x 通常不会互相影响(例如,你得到python3而不是仅仅 .x python)。

于 2013-01-04T02:26:07.903 回答
1

You don't have permission to install to this folder, likely because the command should be run as root (using sudo).


Alternatively, you might want to look into homebrew, which is a package manager for Mac OS. If you install Python through homebrew, it will come bundled with distutils and pip, which is all you should need.

And will be a more up-to-date version of Python too!

于 2013-01-03T23:59:28.307 回答