Search code examples
python-3.xapiodoo-14xmlrpcclient

Odoo 14 API - No module named xmlrpc.client


Hello i'm trying the External API of Odoo so i'm trying something but i have an error when i try to launch my main.py.

import xmlrpc.client


info = xmlrpc.client.ServerProxy('https://demo.odoo.com/start').start()
url, db, username, password = \
     info['host'], info['database'], info['user'], info['password']
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
common.version()

But when i launch this file i have this output :

python main.py                            
Traceback (most recent call last):
File "main.py", line 1, in <module>
      import xmlrpc.client
ImportError: No module named xmlrpc.client

Can someone help me please ? Thanks by advance !


Solution

  • OK I'll answer myself...

    The problem was my Python default version.

    I had Python2.7 et Python3.8, but the priority was set to :

    Python2.7 as "2" (hight priority)

    AND

    Python3.8 as "1" (low priority)

    so i had to change the priority of both by this command :

     update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
     update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2