pytest cannot find module easynmt when I run pytest
my-proj
├── src
│ ├── run.py
│ ├── __init__.py (empty)
└── tests
│ ├── test_run.py
│ ├── test_requirements.txt
|___setup.py
|___conftest.py (empty)
|___pytest.ini
setup.py:
install_requires=['easynmt==2.0.2', 'torch==2.2.2']
run.py:
from easynmt import EasyNMT, models
pytest.ini:
[pytest]
pythonpath = .
test_requirements.txt:
pytest
torch==2.2.2
easynmt==2.0.2
Error:
13:06:26 /usr/lib/python3.11/importlib/__init__.py:126: in import_module
13:06:26 return _bootstrap._gcd_import(name[level:], package, level)
13:06:26 tests/test_run.py:4: in <module>
13:06:26 from an_ml_easynmt_model import oversatt
13:06:26 src/__init__.py:1: in <module>
13:06:26 from an_ml_easynmt_model.run import oversatt
13:06:26 src/run.py:1: in <module>
13:06:26 from easynmt import EasyNMT, models
13:06:26 E ModuleNotFoundError: No module named 'easynmt'
Actually pytest work locally but not in jenkins. Tests is run in jenkins with following bash-script:
python -m venv ./testvenv
source ./testvenv/bin/activate
pip install -U pip
pip install -U setuptools
pip install -U wheel
pip install -r ./tests/test_requirements.txt
pip install -e .
deactivate && source ./testvenv/bin/activate
hash -r
python -m site
pytest tests
deactivate
(I found the deactivate/source “dance” here How do I use pytest with virtualenv?)
Tried putting empty init-files, init-files with src-manipulations, no conftest.py-file, tried running python -m pytest, and more. I’m lost.