Missing zxJDBC connector in sqlalchemy (With DB2) - python

Facing issue with a sqlalchemy + db2(remote server) application.
Dependency installed:
SQLAlchemy==1.4.21
ibm-db==3.0.4
ibm-db-sa==0.3.6
python version = 3.8
Here is the connection snippet:
self.__engine = create_engine(f'ibm_db_sa://{DB2_USER}:{DB2_PASSWD}#{DB2_INSTANCE}/{DB2_DB}')
Seeing below issue:
File "/db-query-service/query_executor/db_reader/db2_reader_with_query.py", line 19, in __init__
self.__engine = create_engine(f'ibm_db_sa://{DB2_USER}:{DB2_PASSWD}#{DB2_INSTANCE}/{DB2_DB}')
File "<string>", line 2, in create_engine
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned
return fn(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 522, in create_engine
entrypoint = u._get_entrypoint()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/url.py", line 653, in _get_entrypoint
cls = registry.load(name)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 337, in load
return impl.load()
File "/usr/local/lib/python3.8/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.8/site-packages/ibm_db_sa/__init__.py", line 22, in <module>
from . import ibm_db, pyodbc, base, zxjdbc
File "/usr/local/lib/python3.8/site-packages/ibm_db_sa/zxjdbc.py", line 32, in <module>
from sqlalchemy.connectors.zxJDBC import ZxJDBCConnector
ModuleNotFoundError: No module named 'sqlalchemy.connectors.zxJDBC'
Questions:
Is there any dependency missing or mismatch in versions?
Is there any issue with sqlalchemy installation? - I removed and reinstalled it to rule that out.
Able to work with Mysql remote db.
zxjdbc is specific to jython i found, will db2+ Sqlalchemy work with jython implementations.?
If db2+ Sqlalchemy work with cpython, what's the fix for the issue?
Reference Doc:
Here is the link

Temporarily, you need to uninstall the sqlalchemy 1.4.x and as a workaround, then install the current sqlalchemy 1.3.x release . At today's date this is sqlalchemy 1.3.24 which should resolve the issue.
I expect this problem will eventually get resolved.
Link to issue is here

Related

AttributeError: module 'collections' has no attribute

ide Pycharm. Google SDK installed lastest. What the problem? i used Python Interpreter 3.10 lastest. frozendict installed lastest, uplink installed, mapping installed
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\pytest_plugin.py", line 9, in <module>
from allure.common import AllureImpl, StepContext
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\vgorbunov\AppData\Local\Programs\Python\Python310\lib\site-packages\_pytest\assertion\rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\common.py", line 19, in <module>
from allure.structure import Attach, TestStep, TestCase, TestSuite, Failure, Environment, EnvParameter
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\vgorbunov\AppData\Local\Programs\Python\Python310\lib\site-packages\_pytest\assertion\rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\structure.py", line 14, in <module>
class Attach(xmlfied('attachment',
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\rules.py", line 116, in xmlfied
class MyImpl(namedlist('XMLFied', [(item[0], None) for item in items])):
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\namedlist.py", line 398, in namedlist
fields, defaults = _fields_and_defaults(typename, field_names, default, rename)
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\namedlist.py", line 252, in _fields_and_defaults
if isinstance(field_names, _collections.Collection):
AttributeError: module 'collections' has no attribute 'Mapping'

Azure function failing after successfull deployment with OSError: [Errno 107]

The function was working before the last deployment. It is used for NLC and we are running two functions for two different languages. For the new deployment we removed some code which was only used for one language and mirrored the code to be equal to the other language. Azure CLI tells us:
Upload completed successfully.
Deployment completed successfully.
But when trying to invoke the function afterwards it either returns 500 without a body or it returns 404 with:
<html>
<head>
<title>404 Not Found</title>
</head>
<body bgcolor="white">
<center>
<h1>404 Not Found</h1>
</center>
<hr>
<center>nginx</center>
</body>
</html>
The stacktrace we can see in the monitoring is the following:
Exception while executing function: Functions.classify Result: Failure
Exception: OSError: [Errno 107] Transport endpoint is not connected: '/home/site/wwwroot/.python_packages/lib/site-packages'
Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 271, in _handle__function_load_request
func = loader.load_function(
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 32, in call
return func(*args, **kwargs)
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 76, in load_function
mod = importlib.import_module(fullmodname)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/site/wwwroot/classify/__init__.py", line 4, in <module>
File "/home/site/wwwroot/classify/predict.py", line 1, in <module>
File "/home/site/wwwroot/.python_packages/lib/site-packages/fastai/text/all.py", line 1, in <module>
File "/home/site/wwwroot/.python_packages/lib/site-packages/fastai/basics.py", line 1, in <module>
File "/home/site/wwwroot/.python_packages/lib/site-packages/fastai/data/all.py", line 1, in <module>
File "/home/site/wwwroot/.python_packages/lib/site-packages/fastai/torch_basics.py", line 1, in <module>
File "/home/site/wwwroot/.python_packages/lib/site-packages/torch/__init__.py", line 482, in <module>
File "/home/site/wwwroot/.python_packages/lib/site-packages/torch/serialization.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 971, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 914, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1342, in find_spec
File "<frozen importlib._bootstrap_external>", line 1314, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1443, in find_spec
File "<frozen importlib._bootstrap_external>", line 1483, in _fill_cache
Commands used for deployment were the following, which worked before:
pip3 install --target="./.python_packages/lib/site-packages" -r requirements.txt
func azure functionapp publish [functionapp name] --no-build
Deleting the python packages and rebuilding etc. did not change anything.
I tried creating a new function app from scratch but it shows the same errors.
I tried to deploy from the folder of the other language with one file swapped (classifier language model) but it
showed the same error. I fear trying to redeploy the working language
for testing as it is working and I don't want to kill it.
It seems to be happening somewhere during module import. Though I am not sure how it was working before (as you mentioned), but I suggest you not to do pip3 install manually and remove --no-build flag to let the func azure functionapp publish handle that. Just make sure you have the requirements.txt in the root.
# no pip install manually
# without --no-build flag
func azure functionapp publish [functionapp name]

Why does pdftotext throw DLL load failed error, on windows10, python3.7

return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\screener\screener\urls.py", line 15, in <module>
from userbase import views as user_views
File "D:\screener\userbase\views.py", line 26, in <module>
from .forms import (
File "D:\screener\userbase\forms.py", line 4, in <module>
from .import_companies import get_codes_from_file
File "D:\screener\userbase\import_companies.py", line 4, in <module>
from utilities.file_to_text import get_text
File "D:\screener\utilities\file_to_text.py", line 3, in <module>
import pdftotext
ImportError: DLL load failed: The specified module could not be found.
I installed folling https://coder.haus/2019/09/27/installing-pdftotext-through-pip-on-windows-10/ , and tried reinstalling using pip command, also tried it inside conda but all yielded the same result
I am unable to import pdftotext, any way to get it done?

Installing Scapy on Android

I did an installation on android using the follow commands on android:
apt install python
pip install scapy
everything is fine for now, but when i run scapy i got this error -----see error
This error does not happen to me in conda or kali, it appears to be exclusive for android.
ERROR: Loading module scapy.layers.netflow
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/scapy/main.py", line 143, in _load
mod = importlib.import_module(module)
File "/data/data/com.termux/files/usr/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/scapy/layers/netflow.py", line 112, in <module>
class NetflowRecordV5(Packet):
File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/scapy/layers/netflow.py", line 127, in NetflowRecordV5
ByteEnumField("prot", IP_PROTOS["tcp"], IP_PROTOS),
File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/scapy/dadict.py", line 49, in getitem
return getattr(self, attr)
AttributeError: 'DADict' object has no attribute 'tcp'
The android device is rooted. I hope someone is familiar with this error and can help. Thanks
i did this on my phone but it looks require root access

Error when importing keyring library in python

I keep getting the same error when I import the keyring library. Just adding 'import keyring' to the code causes this error to appear. I have tried installing the library again, but that didn't solve it.
I'm using python 3.5 in pythonanywhere.
Can somebody help me figure out what might be going on or what I else I can try to do to fix it?
This is the Error message.
Traceback (most recent call last):
File "/home/Marketscale/Tests/OAuth Test.py", line 3, in <module> import keyring
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/__init__.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/core.py", line 149, in <module>
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/core.py", line 65, in init_backend
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/util/__init__.py", line 20, in wrapper
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/backend.py", line 179, in get_all_keyring
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/backend.py", line 139, in _load_backends
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/backend.py", line 131, in _load_backend
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/home/Marketscale/.local/lib/python3.5/site-packages/keyring-10.3.2-py3.5.egg/keyring/backends/SecretService.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/home/Marketscale/.local/lib/python3.5/site-packages/SecretStorage-2.3.1-py3.5.egg/secretstorage/__init__.py", line 13, in <module>
File "/usr/lib/python3/dist-packages/dbus/__init__.py", line 81, in <module> import dbus.exceptions as exceptions
AttributeError: module 'dbus' has no attribute 'exceptions'
>>>
Thank you in advance for any help you can provide.
My guess is that there's some kind of conflict between one of the system-installed modules and the ones you've installed with pip install --user into ~/.local
I suggest switching to a virtualenv to get a "clean" set of modules/dependencies. More info here: https://help.pythonanywhere.com/pages/Virtualenvs

Categories