Is it possible to use tox with conda-based Python installations? Is it possible to use tox with conda-based Python installations? python python

Is it possible to use tox with conda-based Python installations?


The tox-conda plugin should close that gap nowadays, but needs contributors who actively use conda to test and improve it.

from the README:

tox-conda is a plugin that provides integration with the conda package and environment manager for the tox automation tool. It's like having your cake and eating it, too!

By default, tox creates isolated environments using [virtualenv](https://virtualenv.pypa.io] and installs dependencies from pip.

In contrast, when using the tox-conda plugin tox will use conda to create environments, and will install specified dependencies from conda. This is useful for developers who rely on conda for environment management and package distribution but want to take advantage of the features provided by tox for test automation.

To install that plugin it needs to be installed alongside tox in the same virutal environment. To create a virtual environment containing tox and tox-conda this should suffice:

$ python3 -m venv toxbase$ toxbase/bin/pip install tox tox-conda[...]Successfully installed tox-3.13.2 tox-conda-0.2.0$ toxbase/bin/tox --version3.13.1 imported from /home/ob/tmp/toxbase/lib/python3.6/site-packages/tox/__init__.pyregistered plugins:    tox-conda-0.2.0 at /home/ob/tmp/toxbase/lib/python3.6/site-packages/tox_conda/plugin.py

from then on tox can be used as a command line tool and kept current by upgrading it in the toxbase virtualenv. Another, more automated way would be to use pipx


While tox can't make use of conda, you can use conda to "install" different Python versions where tox can find them (like it would find "normal" Python installations in those folders). The following is tested on Windows:

  1. You need virtualenv installed via pip in the root conda environment. I suspect this is the virtualenv that will be used by tox. (I had to install virtualenv using pip install virtualenv to get the virtualenv command to work, even though conda list showed it as installed.)
  2. Install the Python versions you want to test. This is easily done using conda create. tox will autodetect Python binaries on Windows in C:\python27, C:\python33, etc., so create environments using conda create -p C:\python27 python=2.7 etc.


Yes, you need the conda version of virtualenv installed for this to work.

Try to execute:

conda install virtualenvvirtualenv                15.1.0                   py36_

Change to project directory containing tox.ini and execute:

tox