python:easy_install 期间会发生什么?
我对 Egg 文件和使用 easy_install 安装它们有点困惑,希望你能帮助我。 (我读到了人们对 pip 的推荐,但在继续之前我想了解这一点)。
如果我只是从拇指驱动器复制例如 django_guardian-1.0.2-py2.6.egg
并将其放置在 PYTHONPATH 指向的例如 ~/bar/
中,尝试通过 import Guardian
导入内容会产生 importError。即使我现在复制了 easy_install.pth
也会出现此错误
import sys; sys.__plen = len(sys.path)
./django_guardian-1.0.2-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys
'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
,使用 easy_install django-guardian
当然没有这样的问题。
我导航到了 egg 文件 easy_installed 所在的目录,它包含的只是 .pth
和 .egg
文件。我想知道 easy_install 在某个地方做了哪些其他过程/条目,导致第一种方法无法使用......
I'm a little confused about egg files and installing them using easy_install, hope you can help me with it. (I read about people's recommendation on pip, but I'll like to understand this before I move on).
If I simply copy e,g django_guardian-1.0.2-py2.6.egg
from say, a thumbdrive and place in e.g ~/bar/
which PYTHONPATH was pointing to, trying to import the contents via import guardian
would yield me importError. This error occur even if I have the easy_install.pth
copied in
import sys; sys.__plen = len(sys.path)
./django_guardian-1.0.2-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys
'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
Now, using easy_install django-guardian
, of course had no such problem.
I navigated to the directory the egg file was easy_installed to, and all it contains was the .pth
and the .egg
file. I wish to know what other procedures/entries does easy_install makes somewhere that makes the first method unusable....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
easy_install
使用.pth
文件将.egg
文件添加到sys.path
- 位置列表Python 搜索要导入的模块。.pth
文件由site
模块处理,但仅在四个预定义的目录中。这些目录是特定于平台的,并且基于 sys.prefix 和 sys.exec_prefix 设置。在 Unix 上,最突出的通常是/usr/lib/pythonXX/site-packages
。由于您的自定义目录不是
site
处理的目录之一,因此您的.pth
文件不会得到处理,Python 也不会查看.egg 内部
。有关详细信息,请参阅
site
模块文档。easy_install
uses.pth
files to add the.egg
files tosys.path
-- the list of locations where Python searches for modules to import..pth
files are processed by thesite
module, but only in four pre-defined directories. These directories are platform-specific and based on thesys.prefix
andsys.exec_prefix
settings. On Unix, the most prominent usually is/usr/lib/pythonXX/site-packages
.Since your custom directory is not one of the directories processed by
site
, your.pth
file won't get processed and Python won't look inside the.egg
.For more information, see the
site
module documentation.