简体   繁体   English

从 linux 到 windows 的 Conda 环境

[英]Conda environment from linux to windows

I am working on an image processing / computer vision / deep learning app which requires the use of old versions for some Python packages.我正在开发一个图像处理/计算机视觉/深度学习应用程序,它需要对一些 Python 包使用旧版本。 I am new to the world of machine learning and software,it's been 6 months that I made a career change and I am not aware of the best practices when it comes to python projects that work for different platforms (Windows, Linux, MacOS).我是机器学习和软件领域的新手,我在 6 个月内完成了职业转变,我不了解适用于不同平台(Windows、Linux、MacOS)的 python 项目的最佳实践。 So today, I am working on a linux, I did some conda installs and some pip installs and I am exporting my environment to a.yml file.所以今天,我正在研究 linux,我做了一些 conda 安装和一些 pip 安装,我正在将我的环境导出到 a.yml 文件。 How to make sure that creating a virtual environment on a Windows Machine using conda and my exported.yml file is going to work with no problems?如何确保使用 conda 和我的exported.yml 文件在Windows 机器上创建虚拟环境没有问题?

first you create the virtual environment eg首先你创建虚拟环境,例如

pipenv shell

then you write a batch script checking for python packages in that environment:然后您编写一个批处理脚本检查该环境中的 python 包:

echo %time% Check if python packages are installed...
echo ------------------------------------------------------------------------
pip install -r [your .yml file]
echo ------------------------------------------------------------------------

You just have to make sure your .yml file doesn't include platform dependent packages by adding the --from-history flag when creating the file.您只需在创建文件时添加--from-history标志来确保您的.yml文件不包含平台相关包。 This exports only packages you intentionally installed.这只会导出您有意安装的软件包。

On Windows conda will take care of the virtual environment by installing dependencies for the specified packages in the .yml file that are Windows compatible.在 Windows 上, conda将通过在.yml文件中安装与 Windows 兼容的指定包的依赖项来处理虚拟环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM