简体   繁体   English

使用Conda和Tox运行测试时出错

[英]Error running tests with Conda and Tox

I am having trouble running tests with Tox while having virtual environments created with Conda. 使用Conda创建虚拟环境时,使用Tox进行测试时遇到麻烦。 The steps to reproduce the error are below. 重现该错误的步骤如下。

Download the repository (it is small) and cd to it: 下载存储库(它很小)并cd到它:

git clone https://github.com/opensistemas-hub/osbrain.git
cd osbrain

Create the virtual environment with Conda: 使用Conda创建虚拟环境:

conda create -n asdf python=3.5
source activate asdf
pip install tox

Try to run the tests (note that Python 3.5 is the only Python interpreter set in the tox.ini file): 尝试运行测试(请注意,Python 3.5是tox.ini文件中设置的唯一Python解释器):

tox

I would expect Tox to be able to use the Python 3.5 interpreter available in the Conda virtual environment to run the tests. 我希望Tox能够使用Conda虚拟环境中可用的Python 3.5解释器来运行测试。 However, instead, I am getting an error: 但是,相反,我得到一个错误:

ERROR: The executable ~/osbrain/.tox/py35/bin/python3.5 is not 
functioning
ERROR: It thinks sys.prefix is '/usr' (should be '~/osbrain/.tox/py35')
ERROR: virtualenv is not compatible with this system or executable
Running virtualenv with interpreter ~/.miniconda3/envs/asdf/bin/python3.5

My question is: why am I getting that error and how can I avoid this? 我的问题是:为什么我会收到该错误?如何避免此错误? (ie: how could I run the tests locally for this project and using Tox?) (即:如何在此项目中使用Tox在本地运行测试?)

I managed to work around this by installing virtualenv through conda: 我设法通过conda 安装virtualenv来解决此问题:

conda install virtualenv

It's not recommended to use virtualenv yourself (stick with conda environments). 不建议自己使用virtualenv(在conda环境中使用)。 However, when tox looks for the package internally it will at least find a compatible version. 但是,当tox在内部查找软件包时,它至少会找到兼容的版本。

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

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