I've encountered the same issue when trying to use conda environments in CI builds and Docker images. The [conda documentation][1] does provide an example when using Travis CI, but it does not work for me. However, via [this blog][2] I found a working solution! Instead of activating your environment, you can use it by calling `conda run -n my_env python my_file.py`. So, keep everything like it was until you activate your environment. These build specs worked for me when using AWS CodeBuild: ```json { "version": "0.2", "phases": { "pre_build": { "commands": [ "wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh -q", "bash miniconda.sh -b -p $HOME/miniconda", ". \"$HOME/miniconda/etc/profile.d/conda.sh\"", "hash -r", "conda config --set always_yes yes --set changeps1 no", "conda update -q conda", "conda info -a", "conda env create -q -p ./py_env -f environment.yml" ] }, "build": { "commands": [ "conda run -p ./py_env python app.py" ] } } } ``` [1]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/use-conda-with-travis-ci.html [2]: https://pythonspeed.com/articles/activate-conda-dockerfile/