ModuleNotFoundError when running functional python tests despite that textX command works

76 Views Asked by At

I followed the set of instructions for this open source.

At step 3, I am supposed to run

py.test tests/functional/

When I do so, I get

ModuleNotFoundError: No module named 'textx'

However, when I type textx, it's definitely working as a command.

Where did I go wrong?

2

There are 2 best solutions below

2
On

Run export PYTHONPATH=. before running the py.test tests/functional/ and it should work.

This error may have occurred because I installed textX outside my virtual environment after creating the virtual environment.

1
On

The PYTHONPATH is not set by py.test, see https://docs.pytest.org/en/latest/pythonpath.html#pythonpath

As described in https://github.com/igordejanovic/textX/blob/master/CONTRIBUTING.md you install textX in your virtual environment. If you omit 'pip install -e .' you get the described behavior.

As mentioned above, you can set the PYTHONPATH manually. Alternatively you can also run 'python -m pytest tests/functional' as proposed on the py.test website.

It is unclear to me why the textx command works in your example. Maybe you installed textX outside your virtual environment after creating the virtual environment?