Python 为什么可以';我不能在Centos 6 VPS上安装setuptools吗?

Python 为什么可以';我不能在Centos 6 VPS上安装setuptools吗?,python,setuptools,centos6,Python,Setuptools,Centos6,我正在尝试使用Digital Ocean在Centos 6 VPS上安装用于Python2.7的setuptools。当我到达“使用我们已安装的Python(2.7.6)安装所有setuptools”的步骤时,出现以下错误: [username@hotsname setuptools-1.4.2]$ python2.7 setup.py install running install error: can't create or remove files in install directory

我正在尝试使用Digital Ocean在Centos 6 VPS上安装用于Python2.7的setuptools。当我到达“使用我们已安装的Python(2.7.6)安装所有setuptools”的步骤时,出现以下错误:

[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.
现在,我之前遵循了为执行上述根权限的用户提供的权限。当我尝试使用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合作很长一段时间,熟悉安装virtualenv后要做什么,我只是被困在这里,因为这是我第一次安装Centos主机。你能告诉我我错过了什么吗


谢谢大家!

改为root用户就成功了。感谢CasualDemon。

现在,如果您想轻松安装setuptools&pip,可以使用python解释器运行此文件:

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

之后,您可以通过以下方式升级pip和/或setuptools:

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

对于大多数python开发,我建议您只安装setuptools、pip和virtualenv作为root用户(或者如果您比较保守的话,只安装纯virtualenv)。之后,您可以使用虚拟环境创建独立的python环境,而不需要将其安装到python系统或影响其安装的软件包。这样,就不会有其他python(和/或
pip
调用)需要以root用户身份运行。

您可以只执行
sudopython
(不使用2.7)吗?什么是
sudo python--version
说的?CentOS可能很傻。尝试更改为root用户而不是sudo。
sudo su
,然后再次尝试运行
python2.7 setup.py install
。您可能还必须关闭并重新打开SSH连接,以确保环境已正确更新。编辑:I看起来该页面还假设您以root用户身份运行所有命令。@user1781026,sudo python--版本为:python 2.6.6,所以我先试试CasualDemon的想法。。。