I'm trying to setup Circle-CI for the first time for my application. It's a python 3.7.0 based app with a few tests. The app builds just fine, but fails when running the test job. Locally the tests work fine, so I assume I'm missing some Circle-CI configuration?
This is my yaml:
version: 2.0
jobs:
build:
docker:
- image: circleci/python:3.7.0
steps:
- checkout
- run:
name: "Run tests"
command: python -m unittest
This is the error:
======================================================================
ERROR: tests.test_auth (unittest.loader._FailedTest)
ImportError: Failed to import test module: tests.test_auth Traceback (most recent call last): File "/usr/local/lib/python3.7/unittest/loader.py", line 434, in _find_test_path module = self._get_module_from_name(name) File "/usr/local/lib/python3.7/unittest/loader.py", line 375, in _get_module_from_name import(name) File "/home/circleci/project/tests/test_auth.py", line 5, in from werkzeug.datastructures import MultiDict ModuleNotFoundError: No module named 'werkzeug'
What am I missing?
EDIT:
I have added now pip install -r requirements.txt
but I get now:
Could not install packages due to an EnvironmentError: Errno 13] Permission denied: '/usr/local/lib/python3.7/site-packages/MarkupSafe-1.1.1.dist-info'
EDIT:
In addition to the answer, here is complete yaml configuration working:
version: 2.0
jobs:
build:
docker:
- image: circleci/python:3.7.0
steps:
- checkout
- run:
name: "Install dependencies"
command: |
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install --no-cache-dir -r requirements.txt
- run:
name: "Run tests"
command: |
. venv/bin/activate
python -m unittest
It simply means that a dependency 'werkzeug' is not installed. You might need to install additional packages which are required separately.
Consider adding the dependency installations to the Dockerfile something like below
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
If you get permission denied issues, then your tests are started with a user who have no privileges to manage python. But its unlikely to be so.