为什么我不能在Centos 6 VPS上安装setuptools?

时间:2014-03-21 21:09:52

标签: python setuptools centos6

我尝试使用this tutorial在Digital Ocean上安装Centos 6 VPS上的Python2.7的setuptools。当我到达你使用我们安装的Python(2.7.6)"进行安装工具的步骤时,我收到此错误:

[username@hotsname setuptools-1.4.2]$ python2.7 setup.py install
running install
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: '/usr/local/lib/python2.7/site-packages/test-easy-install-1111.write-test'

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

    /usr/local/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:

  https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.

现在,我之前跟着instructions on the same digital ocean community site让用户执行上述root权限。当我尝试使用sudo来完成这项任务时,我得到:

[username@hostname setuptools-1.4.2]$ sudo python2.7 setup.py install
[sudo] password for username: 
sudo: python2.7: command not found

所以我有点困惑。我觉得我可能错过了一些简单的东西。 Digital Ocena无法为此提供进一步的支持。我已经和virtualenv合作了很长时间,并且熟悉安装后我该做什么,我只是在这里,因为这是我第一次设置Centos主机。你能说出我失踪了吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

更改为root用户就可以了。谢谢CasualDemon。

答案 1 :(得分:0)

如今,如果你想安装setuptools&很容易,您可以使用python解释器运行此文件:

get-pip.py

您需要管理员(root)权限才能将其安装到您的系统python中(例如sudo python get-pip.py

之后你可以升级pip和/或setuptools,例如:

$ pip install -U setuptools
$ pip install -U pip

我建议大多数python开发你只安装setuptools,pip和virtualenv作为root(或者纯粹的virtualenv,如果你是保守的)。之后,您可以使用virtualenv虚拟环境来创建隔离的python环境,这些环境不需要安装到系统python或影响其安装的软件包。这样就不需要以root身份运行其他python(和/或pip调用)。