Search code examples
python-3.xbitrix

ImportError: cannot import name 'Bitrix24' from 'bitrix24'


I installed this module https://github.com/gebvlad/bitrix24-python-sdk using pip

python3.8 -m pip install -I bitrix24-python-sdk

When I try to import this module

from bitrix24 import Bitrix24

I am getting the next error

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/vinni/Documents/GitHub/funnel.py", line 2, in <module>
    from bitrix24 import Bitrix24
ImportError: cannot import name 'Bitrix24' from 'bitrix24' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bitrix24/__init__.py)

OS - MacOS 10.15 Python - 3.8


Solution

  • I ran into the same issue, I solved it by using

    from bitrix24.bitrix24 import Bitrix24

    To put it simply, I looked at the modules-directory of Python.

    from bitrix24 is navigating to the directory, .bitrix24 is referring to the bitrix24.py file inside this directory, and import Bitrix24 calls the class inside this file.

    Hope this also helps you find module errors in the future!