如何安装安装工具? [英] How to install setuptools?

查看:71
本文介绍了如何安装安装工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装 setuptools.当我运行sh setuptools-0.6c9-py2.4.egg"时,我收到以下消息:

I'm trying to install setuptools. When I run "sh setuptools-0.6c9-py2.4.egg" I get the following message:

权限被拒绝:'/usr/lib/python2.4/site-packages/test-easy-install-26338.write-test'

Permission denied: '/usr/lib/python2.4/site-packages/test-easy-install-26338.write-test'

这是可以预料的,因为我在系统上没有 root 权限.我是如何产生创建虚拟"Python 的想法的.

It is expectable, since I do not have root permissions on the system. Some how I came to the idea of creating a "Virtual" Python.

我下载了virtual-python.py"并使用站点范围的 Python 运行它.它在我的主目录中创建了lib"、bin"和include"子目录.在virtual-python.py"输出的末尾,我看到以下消息:

I download "virtual-python.py" and run it using the site-wide Python. It creates "lib", "bin" and "include" sub-directories in my home-directory. In the end of the output of "virtual-python.py" I see the following message:

您现在可以下载了ez_setup.py,然后运行/home/myname/bin/python ez_setup.py

You're now ready to download ez_setup.py, and run /home/myname/bin/python ez_setup.py

我下载了这个文件并运行它.但比我收到相同的错误消息:

I download this file and run it. But than I get the same error message:

权限被拒绝:'/usr/lib/python2.4/site-packages/test-easy-install-925.write-test'

Permission denied: '/usr/lib/python2.4/site-packages/test-easy-install-925.write-test'

好的.我使用前缀"强制 ez_setup.py 写入本地目录:

OK. I use "prefix" to force ez_setup.py to write to the local directory:

/home/myname/bin/python ez_setup.py --prefix=~

然后我得到:

  • 您可以通过
    设置安装目录以支持.pth"文件使用所描述的方法之一这里:

http://peak.telecommunity.com/EasyInstall.html#custom-安装位置

因此,我被重定向到我之前阅读的同一页面.所以,我现在不知道该怎么办.

So, I am redirected to the same page which I read before. So, I do not know what to do now.

我还有一个提示:

  • 您可以将安装目录添加到 PYTHONPATH环境变量.(那么它必须每次运行时也要在 PYTHONPATH 上Python 并希望使用软件包您正在安装.)

但是如果我输入:

PYTHONPATH=/home/myname/lib/python2.4/site-packages

我仍然得到相同的结果,就好像 Python 没有看到我的环境变量一样.

I still get the same result as if Python does not see my environment variables.

有人能帮我吗?

推荐答案

只是对已经说过的内容添加额外的细节.

Just adding extra detail to what already have been said.

  1. 下载 tar.gz 最新版本的 virtualenv.
  2. 打开包装.
  3. 你甚至不需要安装它,只需运行virtualenv.py,例如:
    virtualenv-1.3.3/virtualenv.py mypyenv
    mypyenv 虚拟 Python 环境将在您的当前目录中创建,其中包含可供使用的 easy_install.
  4. 激活它:
    source mypyenv/bin/activate
    或在 Windows 上执行:
    mypyenv\Scripts\activate.bat
    现在,您的 PATH 设置为指向 mypyenv 下的 Python 可执行文件.从这个 shell 会话中,您将能够easy_install 任何您想要的东西,并且生成的东西将安装在 mypyenv 的内部而不是您的默认 Python 位置,从而避免任何需要管理员权限.
  1. Download tar.gz of the latest version of virtualenv.
  2. Unpack it.
  3. You don't even need to install it, just run virtualenv.py, for example:
    virtualenv-1.3.3/virtualenv.py mypyenv
    mypyenv virtual Python environment will be created in your current directory and it will contain easy_install ready to use.
  4. Activate it:
    source mypyenv/bin/activate
    or on Windows do:
    mypyenv\Scripts\activate.bat
    Now, your PATH is set to point at Python executables under mypyenv. From this shell session, you will be able to easy_install whatever you want, and resulting stuff will be installed in the guts of mypyenv instead of your default Python location, thus obviating any need for admin privileges.

OS X Snow Leopard 警告:
出于某种原因,virtualenv-1.3.3 不能很好地与 /System/Frameworks 下的内置 Python 配合使用.我必须从源代码构建一个单独的 Python 版本,并将其安装在 /usr/local/python_2_6_2 下.
完成后,我使用了 --python/usr/local/带有 virtualenv 的 python_2_6_2/bin/python 选项.

OS X Snow Leopard caveat:
For some reason, virtualenv-1.3.3 does not play well with built-in Python under /System/Frameworks. I had to build a separate version of Python from source, and installed it under /usr/local/python_2_6_2.
With that done, I used --python /usr/local/python_2_6_2/bin/python option with virtualenv.

这篇关于如何安装安装工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆