Ubuntu + virtualenv = 一团糟?virtualenv 讨厌 dist-packages,想要 site-packages [英] Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages

查看:59
本文介绍了Ubuntu + virtualenv = 一团糟?virtualenv 讨厌 dist-packages,想要 site-packages的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能向我解释一下 ubuntu 9.04 中的 python 发生了什么?

Can someone please explain to me what is going on with python in ubuntu 9.04?

我正在尝试启动 virtualenv,而 --no-site-packages 标志似乎对 ubuntu 没有任何作用.我安装了 virtualenv 1.3.3easy_install(我已经升级到 setuptools 0.6c9),一切似乎都安装到了 /usr/local/lib/python2.6/dist-packages

I'm trying to spin up virtualenv, and the --no-site-packages flag seems to do nothing with ubuntu. I installed virtualenv 1.3.3 with easy_install (which I've upgraded to setuptools 0.6c9) and everything seems to be installed to /usr/local/lib/python2.6/dist-packages

假设在使用 apt-get 安装包时,它被放置在 /usr/lib/python2.6/dist-packages/ ?

I assume that when installing a package using apt-get, it's placed in /usr/lib/python2.6/dist-packages/ ?

问题是,还有一个 /usr/local/lib/python2.6/site-packages 也只是空的.看起来(通过查看 virtualenv 中的 path)这是 virtualenv 用作备份的文件夹.因此,即使我省略了 --no-site-packages,我也无法从任何 virtualenv 访问我的本地系统包.

The issue is, there is a /usr/local/lib/python2.6/site-packages as well that just sits there being empty. It would seem (by looking at the path in a virtualenv) that this is the folder virtualenv uses as backup. Thus even thought I omit --no-site-packages, I cant access my local systems packages from any of my virtualenv's.

所以我的问题是:

  1. 如何让 virtualenv 指向 dist-packages 之一?
  2. 哪些 dist-packages 我应该指向它?/usr/lib/python2.6/dist-packages/usr/local/lib/python2.6/dist-packages/
  3. /usr/lib/python2.6/site-packages 的重点是什么?里面什么都没有!
  4. 在路径上是先到先得吗?如果我在 /usr/local/lib/python2.6/dist-packages/ 中安装了更新版本的包 XYZ,并且在 中安装了旧版本(来自 ubuntu repos/apt-get)/usr/lib/python2.6/dist-packages,当我import xyz 时会导入哪一个?我假设这是基于路径列表,是吗?
  5. 这到底是怎么回事?有什么我在这里遗漏的吗?
  6. 在哪里定义easy_install应该安装到/usr/local/lib/python2.6/dist-packages?
  7. 这也会影响 pip 吗?
  1. How do I get virtualenv to point to one of the dist-packages?
  2. Which dist-packages should I point it to? /usr/lib/python2.6/dist-packages or /usr/local/lib/python2.6/dist-packages/
  3. What is the point of /usr/lib/python2.6/site-packages? There's nothing in there!
  4. Is it first come first serve on the path? If I have a newer version of package XYZ installed in /usr/local/lib/python2.6/dist-packages/ and and older one (from ubuntu repos/apt-get) in /usr/lib/python2.6/dist-packages, which one gets imported when I import xyz? I'm assuming this is based on the path list, yes?
  5. Why the hell is this so confusing? Is there something I'm missing here?
  6. Where is it defined that easy_install should install to /usr/local/lib/python2.6/dist-packages?
  7. Will this affect pip as well?

感谢任何能解决这个问题的人!

Thanks to anyone who can clear this up!

推荐答案

我很想通过将 site-packages 设为 dist-packages 的链接来破解它,但我想这可能会影响您想要安装的其他情况除了来自 ubuntu dist 的一些扩展.除了调整 virtualenv 的源代码(ubuntu 和 virtualenv 都如此受欢迎,我不会惊讶地发现调整版本已经存在)之外,我想不出另一个答案 1.

I'd be tempted to hack it by making site-packages a link to dist-packages, but I guess this might affect other cases where you want to install some extension other than from the ubuntu dist. I can't think of another answer to 1 except tweaking virtualenv's sources (with both ubuntu and virtualenv being so popular I wouldn't be surprised to find tweaked versions already exist).

Re 2,如果您使用的是/usr/local/bin/python,您应该使用/usr/local 版本的 lib(包括站点包),相反,如果您使用的是/usr/bin/python.

Re 2, if you're using /usr/local/bin/python you should use the /usr/local version of the lib (including site-packages) and conversely if you're using /usr/bin/python.

Re 3,如果你从源代码(不是通过 easy_install 或从 ubuntu 的发行版)安装了/usr/bin/python 的扩展,就会有一些东西.

Re 3, there will be something there if you ever install an extension for /usr/bin/python from sources (not via easy_install or from ubuntu's distro).

Re 4,是的,路径上较早的条目优先.

Re 4, yes, earlier entries on the path take precedence.

Re 5,easy_install 只是在它的名字上很简单——它做了很多黑魔法,尽管它很方便,但它被小心地排除在标准 python 库之外,因为我们 python 提交者之间的共识是,为了方便起见,深度黑魔法是容易"只是表面上的.

Re 5, easy_install is easy only in its name -- it does so much dark magic that it's been carefully kept out of the standard python library despite its convenience because the consensus among us python committers is that deep dark magic for convenience is "easy" only on the surface.

Re 6,我认为这是对 easy_install 的 ubuntu 修改——如果这是对的,那么在 Canonical 或其他 ubuntu 维护者做出集体决定的任何地方都定义了它.

Re 6, I think that's an ubuntu modification to easy_install -- if that's right then it's defined wherever Canonical or other ubuntu maintainers make their collective decisions.

Re 7,抱歉,不知道——我手头没有最近的 ubuntu 可以检查.

Re 7, sorry, no idea -- I have no reasonably recent ubuntu at hand to check.

这篇关于Ubuntu + virtualenv = 一团糟?virtualenv 讨厌 dist-packages,想要 site-packages的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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