python – pip找不到安装文件
发布时间:2020-12-20 13:22:28 所属栏目:Python 来源:网络整理
导读:我在尝试使用pip安装 python包时遇到错误. 在解开包后,它在某个目录中查找“setup.py”,但在那里找不到它. setup.py文件实际上是一个目录. 它正在寻找: 'virtualenvs/pyling/build/nltk/setup.py' 但它实际上是: virtualenvs/pyling $ls build/nltk/nltk-2
我在尝试使用pip安装
python包时遇到错误.
在解开包后,它在某个目录中查找“setup.py”,但在那里找不到它. setup.py文件实际上是一个目录. 它正在寻找: 'virtualenvs/pyling/build/nltk/setup.py' 但它实际上是: virtualenvs/pyling $ls build/nltk/nltk-2.0b9/ INSTALL.txt javasrc LICENSE.txt nltk PKG-INFO README.txt setup.py 有没有办法让pip知道包中的这个嵌套文件夹结构? 谢谢 解决方法
我发现pip运行的python命令行脚本如下所示:
__file__ = '<path to package>/setup.py' from setuptools.command import egg_info def replacement_run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in egg_info.iter_entry_points('egg_info.writers'): # require=False is the change we're making: writer = ep.load(require=False) if writer: writer(self,ep.name,egg_info.os.path.join(self.egg_info,ep.name)) self.find_sources() egg_info.egg_info.run = replacement_run execfile(__file__) 在软件包的顶级目录中,没有setup.py,我放置了一个可以重现此行为的setup.py,但是chdir到包含“真正的”setup.py的目录,并在最后执行. 唯一的另一个问题是pip创建了一个目标“pip-egg-info”,它希望填充该目录,需要在具有“真实”setup.py的目录中创建一个符号链接. 新的顶级setup.py看起来像这样: #! /usr/bin/env python from os import chdir,symlink,getcwd from os.path import join,basename,exists filename = basename(__file__) chdir("python") setupdir = getcwd() egginfo = "pip-egg-info" if not exists(egginfo) and exists(join("..",egginfo)): symlink(join("..",egginfo),egginfo) __file__ = join(setupdir,filename) from setuptools.command import egg_info def replacement_run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in egg_info.iter_entry_points('egg_info.writers'): # require=False is the change we're making: writer = ep.load(require=False) if writer: writer(self,ep.name)) self.find_sources() egg_info.egg_info.run = replacement_run execfile(__file__) 它可能很脆弱,但应该继续工作,直到pip更改它生成的命令行python代码 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |