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

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\

Related

redis.client import string_keys_to_dict, dict_merge

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'

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

Alpha Vantage package installed but not able to find it?

Hi I've installed Alpha Vantage I'm getting an error when importing alpha_vantage into my Anaconda project:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_18576/239330141.py in <module>
----> 1 from aplha_vantage import TimeSeries
ModuleNotFoundError: No module named 'aplha_vantage'
Here's how I've installed it:
(base) C:\Users\audac>cd Documents/trading/code
(base) C:\Users\audac\Documents\trading\code>cd stock-scanner-py
(base) C:\Users\audac\Documents\trading\code\stock-scanner-py>cd algorithmic-trading-python
(base) C:\Users\audac\Documents\trading\code\stock-scanner-py\algorithmic-trading-python>pip install alpha_vantage
Requirement already satisfied: alpha_vantage in c:\users\audac\anaconda3\lib\site-packages (2.3.1)
Requirement already satisfied: requests in c:\users\audac\anaconda3\lib\site-packages (from alpha_vantage) (2.26.0)
Requirement already satisfied: aiohttp in c:\users\audac\anaconda3\lib\site-packages (from alpha_vantage) (3.8.1)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (2.0.4)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (6.0.1)
Requirement already satisfied: frozenlist>=1.1.1 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (1.3.0)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (1.7.2)
Requirement already satisfied: aiosignal>=1.1.2 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (1.2.0)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (4.0.2)
Requirement already satisfied: attrs>=17.3.0 in c:\users\audac\anaconda3\lib\site-packages (from aiohttp->alpha_vantage) (21.2.0)
Requirement already satisfied: idna>=2.0 in c:\users\audac\anaconda3\lib\site-packages (from yarl<2.0,>=1.0->aiohttp->alpha_vantage) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\audac\anaconda3\lib\site-packages (from requests->alpha_vantage) (1.26.7)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\audac\anaconda3\lib\site-packages (from requests->alpha_vantage) (2021.10.8)
(base) C:\Users\audac\Documents\trading\code\stock-scanner-py\algorithmic-trading-python>
I've also tried uninstalling Python and all packages + reinstalling them but I still have the same issue. It only happens with the Alpha Vantage package, everything else works fine.
What am I doing wrong?
Spelling error:
aplha_vantage --> alpha_vantage
i.e.
from alpha_vantage import TimeSeries

import boto3 error on Mac OS

I'm trying to install boto3 on my mac (high sierra 10.13.3) and tried to follow : https://github.com/boto/boto3. I had already installed python 3 using homebrew before, but when I tried to see pip --version, I get error.
So, I did
1) modify .bash_profile to add
alias pip=pip3
2) verify
$ pip --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
3)
$ pip install boto3
Collecting boto3
Downloading boto3-1.5.36-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 474kB/s
Collecting botocore<1.9.0,>=1.8.50 (from boto3)
Downloading botocore-1.8.50-py2.py3-none-any.whl (4.1MB)
100% |████████████████████████████████| 4.1MB 376kB/s
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: docutils>=0.10 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in ./Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
Installing collected packages: botocore, boto3
Found existing installation: botocore 1.8.20
Uninstalling botocore-1.8.20:
Successfully uninstalled botocore-1.8.20
Successfully installed boto3-1.5.36 botocore-1.8.50
4) just to make sure this was fine, I ran
$ pip3 install boto3
Requirement already satisfied: boto3 in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: botocore<1.9.0,>=1.8.50 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: docutils>=0.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
5) but, now when I ran import boto3 in Idle, I get error
import boto3
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
I even tried to change path in .bash_profile, but it did not work.
Thoughts?
It worked for me to just copy all of packages with "bolo" in the name from the Python 3.7 folder to the Python 2.7 folder:
/usr/local/lib/python3.7/site-packages $ sudo cp -R boto* /Library/Python/2.7/site-packages/.

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