Skip to Content
Menu
This question has been flagged
2 Replies
5563 Views

Hi everyone,

I'm trying to include an external python package -  googleapiclient - in one of my Odoo models.

I run Odoo in the following way: sudo odoo -d odoo -u my_app-c /etc/odoo/odoo.conf

The output of which odoo is: /usr/bin/odoo

And the content of /usr/bin/odoo is:


#!/usr/bin/python3
# set server timezone in UTC before time module imported
__import__('os').environ['TZ'] = 'UTC'
import odoo

if __name__ == "__main__":   
odoo.cli.main()

I've checked the python path during the execution of this script, and the output is as follows:

[
'/usr/bin',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/usr/local/lib/python3.8/dist-packages',
'/usr/lib/python3/dist-packages'

]

There isn't any site-packages folder in the path, which is where pip installs modules. I've been able to circumvent this by forcing pip to install the googleapiclient package in one of these folders, but this is a very problematic solution.

Can anyone explain to me what is the best way to install external Python dependencies for my custom Odoo module?   

Avatar
Discard
Best Answer

You can create a new directory with proper folder permission.  And 'pip install --target' to that directory. Noted, some packages require dependencies or script/data that won't work if only --target is passed when pip installing, also look into --install-options.  Google pip install to another directory should suffice.
Add this directory to your odoo.conf

This essentially keep the ability to pip install from PyPI while separating global python packages from Odoo. 

Avatar
Discard
Author

Thank you!

Best Answer

Hi everyone

I've faced the same error -mentioned by Fred- when I was creating a new module by scaffold method. I will be appreciate if help me by more detail and step by step solution. I Didn't get the mentioned solutions above. 

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 22
3836
3
Apr 25
1594
0
Mar 25
364
1
Feb 25
4999
3
Dec 24
1628