在conda环境中将pip用作低优先级“通道”

时间:2019-07-19 09:27:51

标签: python pip conda

在conda环境中,是否可以将pip用作某些软件包的“后备”选项,例如您可以拥有多个优先的conda通道?

对于普通的conda频道,我的environment.yml如下:

let arrayFromAPI= [
    {
        bookMarked: false,
        completed: false,
        totalScore: 500,
        current: 250,
        description:
            "<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
        icon: "male-urinary-catheterisation",
        id: 1
    },
    {
        bookMarked: false,
        completed: false,
        totalScore: 750,
        current: 870,
        description:
            "<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
        icon: "male-urinary-catheterisation",
        id: 2
    }
];

let arrayFromPersist = [
    {
        bookMarked: true,
        completed: false,
        totalScore: 50,
        completed: true,
        current: 0,
        description:
            "<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
        icon: "male-urinary-catheterisation",
        id: 1
    },
    {
        bookMarked: true,
        completed: false,
        totalScore: 50,
        completed: true,
        current: 0,
        description:
            "<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
        icon: "male-urinary-catheterisation",
        id: 2
    }
];

function merge(a, b, prop){
  var reduced = a.filter(function(aitem){
      return ! b.find(function(bitem){
          return aitem[prop] === bitem[prop];
      });
  });
  return reduced.concat(b);
}

console.log(merge(arrayFromPersist, arrayFromAPI, "id"))

如果可能的话,将从默认通道中安装name: my_env channels: - defaults - conda-forge dependencies: - some-package>=1.2.3 ,否则将conda-forge安装在该位置。如果两个通道都没有合适的软件包版本,则将失败。

带有pip的environment.yml:

some-package

name: my_env channels: - defaults - conda-forge dependencies: - pip - pip: - some-package>=1.2.3 总是 来自点子的地方。

但是我想要的是这样的:

some-package

该软件包首先来自默认值,否则来自conda-forge,或者来自pip。
但是,这会在尝试pip之前给出ResolvePackageNotFound错误。有什么办法可以做到这一点?

1 个答案:

答案 0 :(得分:1)

我在某处读到了conda应该被扩展以允许满足pip安装的软件包的依赖关系。但是我无法通过快速搜索找到参考,而且我也不认为这是可用于生产的功能。我记得的不是conda安装pip软件包,而是conda接受pip已安装的已经存在的软件包。

Anaconda软件包根据其他Anaconda软件包定义了它们的依赖关系。因此,pip解析Anaconda软件包在其自身的软件包和元数据世界中的依赖性。某些程序包甚至在Anaconda频道和PyPI中甚至没有相同的名称。

换句话说:不,我不认为您想要的是可能的。要由pip安装某些东西时,您必须致电public class BillingManager implements PurchasesUpdatedListener { private static final String TAG = "BillingManager"; private final BillingClient mBillingClient; private final Activity mActivity; public BillingManager(Activity activity) { mActivity = activity; mBillingClient = BillingClient.newBuilder(mActivity).setListener(this).build(); mBillingClient.startConnection(new BillingClientStateListener() { @Override public void onBillingSetupFinished(@BillingClient.BillingResponse int billingResponse) { if (billingResponse == BillingClient.BillingResponse.OK) { Log.i(TAG, "onBillingSetupFinished() response: " + billingResponse); } else { Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse); } } @Override public void onBillingServiceDisconnected() { Log.w(TAG, "onBillingServiceDisconnected()"); } }); } @Override public void onPurchasesUpdated(int responseCode, List<Purchase> purchases) { Log.i(TAG, "onPurchasesUpdated() response: " + responseCode); } public void startPurchaseFlow(String skuId, String billingType) { BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder() .setType(billingType).setSku(skuId).build(); mBillingClient.launchBillingFlow(mActivity, billingFlowParams); Log.i(TAG, "Received command"); }}