redis.client import string_keys_to_dict, dict_merge - python

I have tried using this from both python 3.6 and 3.9 but get the same error:
pip install serialized-redis-interface
Collecting serialized-redis-interface
Using cached serialized_redis_interface-0.3.1-py3-none-any.whl (7.8 kB)
Requirement already satisfied: redis>3 in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from serialized-redis-interface) (4.3.5)
Requirement already satisfied: packaging>=20.4 in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from redis>3->serialized-redis-interface) (21.3)
Requirement already satisfied: typing-extensions in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from redis>3->serialized-redis-interface) (4.1.1)
Requirement already satisfied: importlib-metadata>=1.0 in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from redis>3->serialized-redis-interface) (4.8.3)
Requirement already satisfied: async-timeout>=4.0.2 in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from redis>3->serialized-redis-interface) (4.0.2)
Requirement already satisfied: zipp>=0.5 in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from importlib-metadata>=1.0->redis>3->serialized-redis-interface) (3.6.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/idf/anaconda3/envs/works/lib/python3.6/site-packages (from packaging>=20.4->redis>3->serialized-redis-interface) (3.0.9)
Installing collected packages: serialized-redis-interface
Successfully installed serialized-redis-interface-0.3.1
This code doesn't work (but it used to work, not sure what this new installation broke):
import serialized_redis
def connect_redis(redis_host, redis_port, redis_password):
print("Connecting redis")
try:
# The decode_repsonses flag here directs the client to convert the responses from Redis into Python strings
# using the default encoding utf-8. This is client specific.
redis_connection_object = serialized_redis.JSONSerializedRedis(host=redis_host, port=redis_port, password=redis_password, db=0)
#redis.StrictRedis(host=redis_host, port=redis_port, password=redis_password, decode_responses=True)
if None == redis_connection_object:
print("redis is not connected")
return redis_connection_object
except Exception as e:
print(e)
return None
The error:
Traceback (most recent call last):
File "options.py", line 42, in <module>
from redis_connection import connect_redis
File "/home/idf/Downloads/backup/amplify/redis_connection.py", line 1, in <module>
import serialized_redis
File "/home/idf/anaconda3/envs/works/lib/python3.6/site-packages/serialized_redis/__init__.py", line 5, in <module>
from redis.client import string_keys_to_dict, dict_merge
ImportError: cannot import name 'dict_merge'

Related

Problem with pywhatkit error module not found

I have an issue with pywhatkit:
code:
import pywhatkit
pywhatkit.sendwhatmsg("+39123456789", "Hi", 6, 13)
Result:
Traceback (most recent call last):
File "C:\Users\angelo\Desktop\whatsapp.py", line 1, in
import pywhatkit
File "C:\Users\angelo\AppData\Local\Programs\Python\Python310\lib\site-packages\pywhatkit_init_.py", line 29, in
from pywhatkit.remotekit import start_server
File "C:\Users\angelo\AppData\Local\Programs\Python\Python310\lib\site-packages\pywhatkit\remotekit.py", line 6, in
from flask import Flask, request
ImportError: cannot import name 'Flask' from 'flask' (unknown location)
Installation 1:
pip install pywhatkit.py
ERROR: Could not find a version that satisfies the requirement pywhatkit.py (from versions: none)
ERROR: No matching distribution found for pywhatkit.py
Installation 2:
py -m pip install pywhatkit
Requirement already satisfied: pywhatkit in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (5.3)
Requirement already satisfied: requests in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pywhatkit) (2.28.0)
Requirement already satisfied: wikipedia in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pywhatkit) (1.4.0)
Requirement already satisfied: pyautogui in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pywhatkit) (0.9.53)
Requirement already satisfied: Pillow in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pywhatkit) (9.1.1)
Requirement already satisfied: pymsgbox in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pyautogui->pywhatkit) (1.0.9)
Requirement already satisfied: PyTweening>=1.0.1 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pyautogui->pywhatkit) (1.0.4)
Requirement already satisfied: pyscreeze>=0.1.21 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pyautogui->pywhatkit) (0.1.28)
Requirement already satisfied: pygetwindow>=0.0.5 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pyautogui->pywhatkit) (0.0.9)
Requirement already satisfied: mouseinfo in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pyautogui->pywhatkit) (0.1.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from requests->pywhatkit) (2022.6.15)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from requests->pywhatkit) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from requests->pywhatkit) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from requests->pywhatkit) (1.26.9)
Requirement already satisfied: beautifulsoup4 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from wikipedia->pywhatkit) (4.11.1)
Requirement already satisfied: pyrect in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from pygetwindow>=0.0.5->pyautogui->pywhatkit) (0.2.0)
Requirement already satisfied: soupsieve>1.2 in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from beautifulsoup4->wikipedia->pywhatkit) (2.3.2.post1)
Requirement already satisfied: pyperclip in c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages (from mouseinfo->pyautogui->pywhatkit) (1.8.2)
Path:
C:\Users\angelo\AppData\Local\Programs\Python\Python310\Scripts;C:\Users\angelo\AppData\Local\Programs\Python\Python310;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;%USERPROFILE%.dotnet\tools;c:\users\angelo\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages;c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages;
C:\Users\angelo\AppData\Local\Programs\Python\Python310\
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
%USERPROFILE%.dotnet\tools
c:\users\angelo\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\
c:\users\angelo\appdata\local\programs\python\python310\lib\site-packages\
Any ideas?
Thank you for your help
Angelo
I solved with this line:
python -m install flask
Now it works.
Angelo

AttributeError: module 'miceforest' has no attribute 'MultipleImputedKernel' error

Installed miceForest with !pip install miceforest and no issue with installation
Collecting miceforest
Downloading miceforest-5.2.0-py3-none-any.whl (69 kB)
Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (from miceforest) (1.20.1)
Collecting lightgbm>=3.3.1
Downloading lightgbm-3.3.1-py3-none-win_amd64.whl (1.0 MB)
Requirement already satisfied: wheel in c:\programdata\anaconda3\lib\site-packages (from lightgbm>=3.3.1->miceforest) (0.36.2)
Requirement already satisfied: scikit-learn!=0.22.0 in c:\programdata\anaconda3\lib\site-packages (from lightgbm>=3.3.1->miceforest) (0.24.1)
Requirement already satisfied: scipy in c:\programdata\anaconda3\lib\site-packages (from lightgbm>=3.3.1->miceforest) (1.6.2)
Requirement already satisfied: joblib>=0.11 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn!=0.22.0->lightgbm>=3.3.1->miceforest) (1.0.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn!=0.22.0->lightgbm>=3.3.1->miceforest) (2.1.0)
Installing collected packages: lightgbm, miceforest
Successfully installed lightgbm-3.3.1 miceforest-5.2.0
No issue with below code
import miceforest as mf
from sklearn.datasets import load_iris
import pandas as pd
import numpy as np
But getting error while referring to MultipleImputedKernel
-------------------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-10-b346f2744b14> in <module>
----> 1 kernel = mf.MultipleImputedKernel(
2 iris_amp,
3 datasets=4,
4 save_all_iterations=True,
5 random_state=1991
AttributeError: module 'miceforest' has no attribute 'MultipleImputedKernel'
-------------------------------------------------------------------------------
Any help to fix the issue will be greatly appreciated
New main classes (ImputationKernel, ImputedData) have replaced (KernelDataSet, MultipleImputedKernel, ImputedDataSet, MultipleImputedDataSet).

Unable to list s3 buckets, getting error like "AttributeError: module 'boto3' has no attribute 'client'"

I'm getting the error like below:
AttributeError: module 'boto3' has no attribute 'client'
My python snippet is as like below
[ansible#ip-172-31-40-59 python]$ cat lists3buckets.py
#import boto3
#s3 = boto3.resource('s3')
#obj = s3.Object(bucketname, itemname)
#body = obj.get()['Body'].read()
#import boto3
#from botocore import ClientError
#s3 = boto3.client('s3')
#for bucket in s3.list_buckets():
# print(bucket)
import boto3
from botocore.exceptions import ClientError
s3=boto3.client('s3')
for i in s3.list_buckets():
print(i)
Note: I did try the commented code as well but had no luck.
My environment is Amazon Linux 2 machine and has boto3 and botocore already installed.
[ansible#ip-172-31-40-59 python]$ pip3 install boto3 --upgrade --user
Collecting boto3
Using cached https://files.pythonhosted.org/packages/85/c6/00e25614edf5ac025684bcc7af4c750187249ea7abbfc19dac05b95e83e8/boto3-1.14.22.tar.gz
Requirement already up-to-date: botocore<1.18.0,>=1.17.22 in /usr/local/lib/python3.7/site-packages (from boto3)
Requirement already up-to-date: jmespath<1.0.0,>=0.7.1 in /home/ansible/.local/lib/python3.7/site-packages (from boto3)
Requirement already up-to-date: s3transfer<0.4.0,>=0.3.0 in /home/ansible/.local/lib/python3.7/site-packages (from boto3)
Requirement already up-to-date: urllib3<1.26,>=1.20; python_version != "3.4" in /home/ansible/.local/lib/python3.7/site-packages (from botocore<1.18.0,>=1.17.22->boto3)
Requirement already up-to-date: python-dateutil<3.0.0,>=2.1 in /home/ansible/.local/lib/python3.7/site-packages (from botocore<1.18.0,>=1.17.22->boto3)
Requirement already up-to-date: docutils<0.16,>=0.10 in /home/ansible/.local/lib/python3.7/site-packages (from botocore<1.18.0,>=1.17.22->boto3)
Requirement already up-to-date: six>=1.5 in /home/ansible/.local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.18.0,>=1.17.22->boto3)
Installing collected packages: boto3
Found existing installation: boto3 1.14.17
Uninstalling boto3-1.14.17:
Successfully uninstalled boto3-1.14.17
Running setup.py install for boto3 ... done
Successfully installed boto3-1.14.22
[ansible#ip-172-31-40-59 python]$ pip3 install botocore --upgrade --user
Requirement already up-to-date: botocore in /usr/local/lib/python3.7/site-packages
Requirement already up-to-date: jmespath<1.0.0,>=0.7.1 in /home/ansible/.local/lib/python3.7/site-packages (from botocore)
Requirement already up-to-date: urllib3<1.26,>=1.20; python_version != "3.4" in /home/ansible/.local/lib/python3.7/site-packages (from botocore)
Requirement already up-to-date: python-dateutil<3.0.0,>=2.1 in /home/ansible/.local/lib/python3.7/site-packages (from botocore)
Requirement already up-to-date: docutils<0.16,>=0.10 in /home/ansible/.local/lib/python3.7/site-packages (from botocore)
Requirement already up-to-date: six>=1.5 in /home/ansible/.local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore)
I'm executing script as below:
[ansible#ip-172-31-40-59 python]$ !p
python3 lists3buckets.py
Traceback (most recent call last):
File "lists3buckets.py", line 14, in <module>
s3=boto3.client('s3')
AttributeError: module 'boto3' has no attribute 'client'
I fail to understand why a simple snippet should not work?

How to fix "UnicodeDecodeError" for EbookLib when installing Textract?

When trying to install the Textract package in pycharm on Windows 10, the package installer returns a UnicodeDecodeError for EbookLib 0.15 in the README.md.
I have attempted the solutions provided at: https://github.com/deanmalmgren/textract/issues/194
and the solutions provided almost worked for EbookLib except running pip install textract
in terminal does not seem to install the actual module.
E:\Main>pip install textract
Requirement already satisfied: textract in e:\conda\lib\site-packages (1.6.1)
Requirement already satisfied: EbookLib==0.15 in e:\ebooklib-0.15 (from textract) (0.15)
Requirement already satisfied: python-pptx==0.6.5 in e:\conda\lib\site-packages (from textract) (0.6.5)
Requirement already satisfied: argcomplete==1.8.2 in e:\conda\lib\site-packages (from textract) (1.8.2)
Requirement already satisfied: docx2txt==0.6 in e:\conda\lib\site-packages (from textract) (0.6)
Requirement already satisfied: SpeechRecognition==3.6.3 in e:\conda\lib\site-packages (from textract) (3.6.3)
Requirement already satisfied: xlrd==1.0.0 in e:\conda\lib\site-packages (from textract) (1.0.0)
Requirement already satisfied: six==1.10.0 in e:\conda\lib\site-packages (from textract) (1.10.0)
Requirement already satisfied: chardet==2.3.0 in e:\conda\lib\site-packages (from textract) (2.3.0)
Requirement already satisfied: beautifulsoup4==4.5.3 in e:\conda\lib\site-packages (from textract) (4.5.3)
Requirement already satisfied: pocketsphinx==0.1.3 in e:\conda\lib\site-packages (from textract) (0.1.3)
Requirement already satisfied: lxml in e:\conda\lib\site-packages (from EbookLib==0.15->textract) (4.3.3)
Requirement already satisfied: XlsxWriter>=0.5.7 in e:\conda\lib\site-packages (from python-pptx==0.6.5->textract)
(1.1.8)
Requirement already satisfied: Pillow>=2.6.1 in e:\conda\lib\site-packages (from python-pptx==0.6.5->textract) (6.0
.0)
>>>import textract
Traceback (most recent call last):
File "E:/Main/Main.py", line 22, in <module>
import textract
ModuleNotFoundError: No module named 'textract'
The installer should properly receive the EbookLib version and run its setup.py but it ends up using the flawed version that has been cached rather than the local file I have decoded.
Collecting EbookLib==0.15 (from textract)
Using cached https://files.pythonhosted.org/packages/04/30/2cbf65fa9587a1ecc66a78eea91f9189ead8fdadd5e009115bce34529aa6/EbookLib-0.15.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Feraz\AppData\Local\Temp\pycharm-packaging\EbookLib\setup.py", line 13, in <module>
long_description = open('README.md').read(),
File "E:\Python37\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1671: character maps to <undefined>
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\Feraz\AppData\Local\Temp\pycharm-packaging\EbookLib\

Unable to install python module paramiko successfully on mac

1)Installed paramiko on mac, but getting some different errors.
pip install paramiko
Requirement already satisfied: paramiko in /Library/Python/2.7/site-packages
Requirement already satisfied: pynacl>=1.0.1 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: bcrypt>=3.1.3 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: cryptography>=1.1 in /Library/Python/2.7/site-packages (from paramiko)
Requirement already satisfied: six in ./2.7/Extras/lib/python (from pynacl>=1.0.1->paramiko)
Requirement already satisfied: cffi>=1.4.1 in /Library/Python/2.7/site-packages (from pynacl>=1.0.1->paramiko)
Requirement already satisfied: idna>=2.1 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: ipaddress in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: asn1crypto>=0.21.0 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: enum34 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi>=1.4.1->pynacl>=1.0.1->paramiko)
Open the terminal, type python. Now in python prompt, import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/paramiko/__init__.py", line 31, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 57, in <module>
from paramiko.ed25519key import Ed25519Key
File "/Library/Python/2.7/site-packages/paramiko/ed25519key.py", line 22, in <module>
import nacl.signing
File "/Library/Python/2.7/site-packages/nacl/signing.py", line 19, in <module>
import nacl.bindings
File "/Library/Python/2.7/site-packages/nacl/bindings/__init__.py", line 17, in <module>
from nacl.bindings.crypto_box import (
File "/Library/Python/2.7/site-packages/nacl/bindings/crypto_box.py", line 18, in <module>
from nacl._sodium import ffi, lib
ImportError: dlopen(/Library/Python/2.7/site-packages/nacl/_sodium.so, 2): Symbol not found: _crypto_box
Referenced from: /Library/Python/2.7/site-packages/nacl/_sodium.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/nacl/_sodium.so
2) After trying some different options, tried sudo -H pip install paramiko and import paramiko from python prompt didn't result into any error.
But when executed paramiko login snippet, resulted into an error Client.py and transport.py & module error certificate transparency

Categories

Resources