ImportError: cannot import name 'Bitrix24' from 'bitrix24' - python-3.x

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

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!

Related

when install any package using pip i get error can't import mapping from collection?

I work on python 3.10 i face error and i can't solve it .
this error display when try to install new package or
using any pip related command
python 3.10 already installed but can't add New Package using pip
this error as below got it from command prompt
C:\Program Files\Python310>pip list
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\connectionpool.py", line 29, in <module>
from .connection import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\connection.py", line 39, in <module>
from .util.ssl_ import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\__init__.py", line 3, in <module>
from .connection import is_connection_dropped
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\connection.py", line 3, in <module>
from .wait import wait_for_read
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\wait.py", line 1, in <module>
from .selectors import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\selectors.py", line 14, in <module>
from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Program Files\Python310\lib\collections\__init__.py)
so what i do to solve issue please ?
Last Updated Post
I delete folder urllib3 from path and execute command below to reinstall again .
but i get error as
C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor>pip install -U urllib3
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.urllib3'
this is collections init.py file
https://pastebin.com/ADc9dV3b
so what i modify or on which place i will modify
From Python 3.3 to 3.9, import Mapping from collections raised a DeprecationWarning:
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
Since Python 3.10, it doesn't work anymore. It looks like you are using an old version of urllib3 because the selector.py file exists only on versions 1.20, 1.21 and 1.22. The current version is 1.26.
Upgrade urllib3 should solve the problem:
[...]# pip install -U urllib3
Update
Maybe you can remove manually the urllib3-X.Y.Z.dist-info and urllib3 folders in C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\. After that reinstall urllib3.
Try editing the file
(C:\Program Files\Python310\lib\collections_init_.py )
and add to the import
from collections.abc import Mapping
Just add to collections (.abc)
To get collections.abc

OSError: [WinError 126] while importing seaborn package

I got an example project from my friend that uses seaborn package to draw maps. I've opened project in pycharm, created venv, installed all needed packages and tried to run his code. Unfortunately code returns an error while importing package seaborn:
Traceback (most recent call last):
File "C:/Users/Carlito/Desktop/Maps/map.py", line 6, in <module>
from seaborn import set
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\rcmod.py", line 7, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\palettes.py", line 9, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\utils.py", line 6, in <module>
from scipy import stats
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\scipy\__init__.py", line 136, in <module>
from . import _distributor_init
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126]
I have tried manually installing all dependencies of this package but it didn't work. These are packages that I've installed:
One maybe important detail, my friend uses Linux Mint, while I am trying to run the project on Windows 10.
Anyone knows what is going on here?
More info required, give this a try
Check for paths hardcoded and try changing to windows backslashes
Example
Here the filepath is given C:/Users/Carlito/Desktop/Maps/map.py, which is Linux , try
Windows
C:\Users\Carlito\Desktop\Maps\map.py
C:\\Users\\Carlito\\Desktop\\Maps\\map.py

unable to run a python file because of Module not found error despite sourcing the pythonpath

I have been trying to run a python file using rosrun command but unfortunately I am having this module not found error because of a package named rospkg. Until a day before yesterday, it was all working fine but yesterday, ubuntu18.04 has got some updates out of which an update for ubuntu base was also present, since that update I am having this error.
I have tried to check whether I have installed the respective python-rospkg and its says I already have the latest version. I have also using
echo $PYTHONPATH
to check the sourced paths and they are sourced correct, I am not sure whats causing this error.
the error is as follows
Traceback (most recent call last
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 5, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest
File "/opt/ros/melodic/lib/python2.7/dist-
packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
The shebang for my is as follows,
#!/usr/bin/python3
When i try to run the file by changing the shebang to
#!/usr/bin/python2.7
I get the following error
Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py",
line 3, in <module>
import tensorflow as tf
ImportError: No module named tensorflow
I have installed tensorflow version 1.14 using pip installation. Can anyone please help me solving this error. Thanks in advance
edit:
I have manually tried to set the python path to /usr/lib/python2.7/dist-packages as when I tried to install python-rospkg, it says the its already instaled in that location. Doing that I am having error importing tensorflow and the error is
`Traceback (most recent call last):
File
"/home/microbot/catkin_ws/src/spider/spider_control/control.py", line
3, in <module>
import tensorflow as tf
File "/home/microbot/.local/lib/python3.6/site-
packages/tensorflow/__init__.py", line 22, in <module>
import inspect as _inspect
File "/usr/lib/python3.6/inspect.py", line 41, in <module>
import linecache
File "/usr/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/usr/lib/python3.6/tokenize.py", line 33, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:`

Builtin module not found when executing python script from cmd (python 3.6.5)

Please can you help, I am trying to run a python script from Windows cmd. The error message I get is:
File "C:\Program Files (x86)\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\compat\__init__.py", line 48, in <module>
import __builtin__ as builtins
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\IndexTrader\code\futures_calc.py", line 16, in <module>
import pandas as pd
File "C:\Program Files (x86)\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "C:\Program Files (x86)\WinPython\python-3.6.5.amd64\lib\site-packages\pandas\compat\__init__.py", line 61, in <module>
import http.client as httplib
File "C:\Program Files (x86)\WinPython\python3.6.5.amd64\lib\http\client.py", line 71, in <module>
import email.parser
I run the python script within Spyder and python and the code executes with no problem or errors.
I am not sure what builtin package it is referring to. I beleieve the issue is with the pandas package (which I uninstalled and reinstalled).
I have successfully run the script from cmd before, so I am not sure what the issue is. I have also reinstalled WinPython, but this has not helped.
I am not sure what to do, I checked the system paths and everything is in order, I also added a PYTHONPATH as a System variable, but no luck.
Any ideas?

Jython ImportError: No module named urllib

Just installed Jython 2.7beta3 and pip under Jython in mac os x
try to run /usr/local/Cellar/jython/2.7-b3/libexec/bin/pip install requests
Get error:
Traceback (most recent call last):
File "./pip", line 8, in <module>
sys.exit(
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 519, in load_entry_point
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 2630, in load_entry_point
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 2310, in load
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/setuptools-11.3.1-py2.7.egg/pkg_resources/__init__.py", line 2316, in resolve
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/pip-6.0.6-py2.7.egg/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/Cellar/jython/2.7-b3/libexec/Lib/site-packages/pip-6.0.6-py2.7.egg/pip/vcs/__init__.py", line 8, in <module>
from pip._vendor.six.moves.urllib import parse as urllib_parse
ImportError: No module named urllib
I found I can't install anything by pip under jython.
Please help me fix it, thanks.
I had the same problem trying to use pip for Jython2.7b3.
I downloaded this:
https://github.com/jythontools/pip/tree/master
And ran the command:
Jython setup.py install
And pip is now up and running like a charm.

Resources