【问题标题】:Why can't I install setuptools on my Centos 6 VPS?为什么我不能在我的 Centos 6 VPS 上安装 setuptools?
【发布时间】:2014-03-21 21:09:51
【问题描述】:

我正在尝试使用this tutorial 在带有 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.

现在,我之前关注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 主机。你能告诉我我错过了什么吗?

谢谢!

【问题讨论】:

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

标签: python setuptools centos6


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    现在,如果你想轻松安装 setuptools 和 pip,你可以用你的 python 解释器运行这个文件:

    get-pip.py

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-21
      • 2019-12-16
      • 2011-10-20
      • 1970-01-01
      • 2021-10-18
      • 2012-02-18
      • 1970-01-01
      相关资源
      最近更新 更多