camptocamp / pytest-odoo

pytest plugin to run Odoo tests
GNU Affero General Public License v3.0
68 stars 45 forks source link

No module named 'odoo' #56

Closed mevimo closed 1 year ago

mevimo commented 1 year ago

I don't understand, the script is invoked by pytest, under Python site-packages. How could it ever find Odoo there to import?

simahawk commented 1 year ago

it must be installed in the same python env where odoo is installed. And you have to follow this instructions https://github.com/camptocamp/pytest-odoo#usage

mevimo commented 1 year ago

My question was not how to get it to work, I can do that just fine. Let me rephrase: I don't see how anyone's Odoo directory can end up in pythonpath automatically, so either I'm missing something or the readme is.

Jerther commented 1 year ago

@MeViMo I'm using PyCharm for development, and that's how I do it: image

So I just have Odoo in my project and use PyCharm's "Project Dependencies".

sebalix commented 1 year ago

@MeViMo you have to install odoo as a Python package in the same Python environment where you installed pytest, let's say you git-cloned Odoo in ./src/:

$ cd ./src/
$ pip install -r requirements.txt
$ pip install -e .
$ python
>>> import odoo
>>> odoo
<module 'odoo' from '[...]/src/odoo/__init__.py'>
>>>
$ which odoo
[...]/src/.venv/bin/odoo
mevimo commented 1 year ago

Damn, my bad, I didn't even realize Odoo had a setup.py and people were installing it as a Python package.

sebalix commented 1 year ago

I checked on the official documentation and this install is not documented (or partially, some bits are missing)...