简体   繁体   English

您如何在使用 virtualenv 创建的环境中 conda 安装库?

[英]How do you conda install a library in an environment created with virtualenv?

I'm working on a (python) project where the choice was to create a virtual environment using virtualenv.我正在研究一个(python)项目,该项目的选择是使用 virtualenv 创建一个虚拟环境。 However, one of the project dependencies can't be installed through pip on macOS due to this bug: https://github.com/streamlit/streamlit/issues/283但是,由于此错误,无法在 macOS 上通过 pip 安装项目依赖项之一: https : //github.com/streamlit/streamlit/issues/283

The workaround is to conda install one of the dependencies to bypass the gcc compiler.解决方法是 conda 安装依赖项之一以绕过 gcc 编译器。

How do you conda install something in a virtual environment not created with conda?您如何在不是用 conda 创建的虚拟环境中 conda 安装某些东西?

I think the easiest approach would be to create a conda env by it's own.我认为最简单的方法是自己创建一个 conda env。

1) Create a requirement.txt file by doing pip freeze > requirements.txt inside your virtualenv environment 1) 通过在 virtualenv 环境中执行pip freeze > requirements.txt创建一个 requirements.txt 文件

2) Create conda env: conda create --name myenv 2)创建conda env: conda create --name myenv

3) Activate your environment: source activate myenv 3)激活你的环境: source activate myenv

4) Install your dependencies: conda install --file requirements.txt 4) 安装您的依赖项: conda install --file requirements.txt

5) Install missing dependecy: conda install YOUR_MISSING_DEPENDENCY 5)安装缺少的依赖: conda install YOUR_MISSING_DEPENDENCY

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

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