콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
6797 화면

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. 

아바타
취소
관련 게시물 답글 화면 활동
1
7월 22
4613
1
6월 25
1547
3
7월 25
3216
1
5월 25
1368
1
5월 25
1617