
Run these commands: conda install virtualenv

This doesn’t need to be anything special, other than making sure that virtualenv is installed in it. We will create conda environments and make sure tox/virtualenv can find them. It might feel a bit unnatural at first to be using a virtualenv within a conda environment (it does to me anyway), but it does seem to get the job done. We can use anaconda to manage the python installations (and other packages) that Tox needs to work. Local(‘C:\Program Files\ffmpeg\bin\ffmpeg.EXE’) See exactly how Tox implements this by looking at the method ‘ tox_get_python_executable‘ in ‘ interpreters.py‘ Tox With Anaconda At the time of writing these are the only places Tox will look (so you will have problems if you have installed python elsewhere, such as ‘D:\pythonx.y’). On windows machines, Tox tries the ‘sysfind’ approach first, but also checks the common python install location ‘C:\pythonx.y’. Running py.(‘ffmpeg’) returns the following. On non-windows machines, Tox uses py.() to look in your system PATH for ‘pythonx.y’.įor example, I have ‘ffmpeg’ installed on my machine. How exactly Tox finds the corresponding python installation on your system depends on your operating system. Tox interprets the ‘envlist’ elements pyxy as python ‘major’.’minor’ on your system. Tox Finds Python Installations on Your System Learn more about how virtualenv creates an isolated virtual environment. The virtualenv (with its link to an existing install) can sit inside a project folder. C:\python 2.7 in windows or /usr/bin/python in Linux – and makes a new folder for installed modules. Without going into too much detail, a virtualenv creates a link to an existing python installation – e.g.

This file tells tox which versions of python you are interested in, and the tests you would like to run for each version – the ‘test environment’.Ĭommands = pytest Tox Creates ‘virtualenv’ Virtual Environmentsįor each one of the python versions in ‘envlist’ Tox will create a ‘virtualenv’ – an isolated python environment. Tox is controlled via the ‘tox.ini’ file. Thankfully, it is possible to use anaconda to create the python versions that tox needs. Tox does not currently support conda so we cannot just tell it to create conda environments rather than virtualenvs. Tox relies on the concept of the virtualenv, and as an anaconda user, I am more familiar with creating and using conda environments. If, like me, you like to use the anaconda python distribution, you will find that it is not obvious how you can incorporate Tox into your workflow.


This post shows you how you can use tox with anaconda. You don’t want to have to manually run tests againsts each of your supported versions. This is useful when, for example, you need to support several different versions of python. Tox is a tool for building and running a matrix of test environments.
