使用本地pip安装导出conda环境 [英] Exporting a conda environment with local pip installs

查看:850
本文介绍了使用本地pip安装导出conda环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用

conda env export > environment.yml

这非常方便,因为它可以跟踪conda和pip安装的软件包.但是,我从Christoph Gohlke的Windows编译软件包的.whl文件中通过pip在本地安装了一些软件包(例如,形状和底图).当我尝试通过

This is very convenient since it keeps track of both conda and pip installed packages. However, I have a few packages (shapely and basemap for example) installed locally by pip from a .whl file from Christoph Gohlke's compiled packages for Windows. When I try to recreate my environment by

conda env create -f environment.yml

pip返回错误,因为它(显然)无法在其索引中找到这些软件包.有没有办法在conda导出步骤中告诉pip在哪里寻找这些本地软件包?可以假定.whl文件与environment.yml文件位于同一目录中.

pip returns with an error since it cannot find these packages in its index (obviously). Is there a way to tell pip in the conda export step where to look for these local packages? The .whl files can be assumed to be in the same directory as the environment.yml file.

推荐答案

无法通过我所知道的方法实际获取它来自动为.whl文件创建条目.

There's no way to actually get it to create entries for the .whl file automatically from what I'm aware of.

最简单的方法是手动更改environment.yml文件并在- pip:下的列表中添加.whl文件.我通过下载nose.whl软件包并将其放置在与我的env.yml文件相同的目录中来进行尝试,其结构如下所示:

The simplest way to get this to work is by manually altering the environment.yml file and adding the .whl file in the list under - pip:. I tried this by downloading the .whl package for nose and placing it in the same directory as my env.yml file, the structure looked like this:

name: python3_test
dependencies:
- openssl=1.0.2h=1
- pip=8.1.2=py35_0
- python=3.5.1=5
- readline=6.2=2
- setuptools=23.0.0=py35_0
- sqlite=3.13.0=0
- tk=8.5.18=0
- wheel=0.29.0=py35_0
- xz=5.2.2=0
- zlib=1.2.8=3
- pip:
   - nose-1.3.7-py3-none-any.whl

如果它位于其他目录中,请提供该目录.当然,发布conda create env时该路径应该是有效的.

If it is located in a different directory, just supply the directory. The path, of course, should be valid when issuing conda create env.

运行conda env create -n <name> -f <file.yml>时发出的pip命令是非常简单的安装,因此从命令行使用pip进行安装的语义应该相似.哎呀,您甚至可以在requirements.yml中为.whl文件添加url,安装仍然可以顺利进行.同样,保持其余部分不变,并使用URL下载nose:

The pip command issued when running conda env create -n <name> -f <file.yml> is a pretty straightforward install so the semantics of installing with pip from the command line should be similar. Heck, you could even add the url for the .whl file in the requirements.yml and the installation would still go down smoothly. Again, keeping the rest the same and using the url for downloading nose:

- pip:
   - https://pypi.python.org/packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl#md5=3135984cc9cfcbe5d9c46e166d6743b0

使用任何网址都不会引起任何问题.

Using any url shouldn't cause any issue.

这篇关于使用本地pip安装导出conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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