pip安装了 但是python找不到_python – pip找不到安装文件

我发现pip运行的python命令行脚本如下所示:

__file__ = '/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, egg_info.os.path.join(self.egg_info,ep.name))

self.find_sources()

egg_info.egg_info.run = replacement_run

execfile(__file__)

它可能很脆弱,但应该继续工作,直到pip更改它生成的命令行python代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值