Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
5886 Представления

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?   

Аватар
Отменить
Лучший ответ

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. 

Аватар
Отменить
Автор

Thank you!

Лучший ответ

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. 

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
июл. 22
3951
1
мая 25
195
0
мая 25
221
1
мая 25
574
4
мая 25
1883