No module named 'importlib.metadata' even after installing it - python-3.x

File
"/home/username/.local/lib/python3.7/site-packages/kodi_cli.py", line
3, in
import importlib.metadata ModuleNotFoundError: No module named 'importlib.metadata'
pip3 install kodi-cli --user
Looking in indexes: https://pypi.org/simple,
https://www.piwheels.org/simple Requirement already satisfied:
kodi-cli in /home/username/.local/lib/python3.7/site-packages (0.1.9)
Requirement already satisfied: requests<3.0.0,>=2.28.0 in
/home/username/.local/lib/python3.7/site-packages (from kodi-cli)
(2.28.1) Requirement already satisfied: urllib3<1.27,>=1.21.1 in
/usr/lib/python3/dist-packages (from
requests<3.0.0,>=2.28.0->kodi-cli) (1.24.1) Requirement already
satisfied: charset-normalizer<3,>=2 in
/home/username/.local/lib/python3.7/site-packages (from
requests<3.0.0,>=2.28.0->kodi-cli) (2.0.4) Requirement already
satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from
requests<3.0.0,>=2.28.0->kodi-cli) (2018.8.24) Requirement already
satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from
requests<3.0.0,>=2.28.0->kodi-cli) (2.6)
kodi-cli -H host -P 8080 -u username -p password -C
I got the error at top so..
pip3 install importlib-metadata --user
Looking in indexes: https://pypi.org/simple,
https://www.piwheels.org/simple Requirement already satisfied:
importlib-metadata in
/home/username/.local/lib/python3.7/site-packages (5.0.0) Requirement
already satisfied: zipp>=0.5 in
/home/username/.local/lib/python3.7/site-packages (from
importlib-metadata) (3.10.0) Requirement already satisfied:
typing-extensions>=3.6.4; python_version < "3.8" in
/home/username/.local/lib/python3.7/site-packages (from
importlib-metadata) (3.10.0.0)
Still get the error.
python3 --version
Python 3.7.3
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux"
VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster
ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
I'm scratching my head here. Any help would be appreciated.
I suspect it might have to do with this code in the program kodi_cli.py
import importlib.metadata
import json
import logging
import os
import pathlib
import sys
import textwrap
import version as ver_info
from kodi_interface import KodiObj
__version__ = importlib.metadata.version("kodi-cli")

Related

Why I can't import Flask?

I followed the Flask instructions and I successfully installed Flask by using Command Prompt.
C:\Users\DELL>py -3 -m pip install flask
C:\Users\DELL>py -3 -m pip install flask
Requirement already satisfied: flask in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (1.1.2)
Requirement already satisfied: itsdangerous>=0.24 in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (from flask) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (from flask) (2.11.2)
Requirement already satisfied: Werkzeug>=0.15 in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (from flask) (1.0.1)
Requirement already satisfied: click>=5.1 in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (from flask) (7.1.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\dell\appdata\local\programs\python\python39\lib\site-packages (from Jinja2>=2.10.1->flask) (1.1.1)
However when I use PyCharm to import flask, it doesn't recognize flask.
ModuleNotFoundError: No module named 'flask'
The most probable problem is py command is related with python2 and flask module is installed in your python3 site-packages. So try to execute explicitly with python3 as :
python3 app.py

How to run a python3 installed package?

I installed a package to python3.7 but when I try to run the executable its getting invoked from python2.7 and it fails as its not present in python3.7
$ sudo -H pip install blobbycompanyconnect --index https://pypi.company.com/simple --user
Looking in indexes: https://pypi.company.com/simple, https://pypi.company.com/simple
Requirement already satisfied: blobbycompanyconnect in /private/var/root/.local/lib/python3.7/site-packages (1.0.0)
Requirement already satisfied: trovecompanyconnect<3.0,>=2.0 in /private/var/root/.local/lib/python3.7/site-packages (from blobbycompanyconnect) (2.0.2)
Requirement already satisfied: filelock==3.0.12 in /private/var/root/.local/lib/python3.7/site-packages (from blobbycompanyconnect) (3.0.12)
Requirement already satisfied: python-dateutil in /private/var/root/.local/lib/python3.7/site-packages (from blobbycompanyconnect) (2.8.1)
Requirement already satisfied: backoff<2.0.0,>=1.8.0 in /private/var/root/.local/lib/python3.7/site-packages (from trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (1.10.0)
Requirement already satisfied: argcomplete<2.0.0,>=1.6.0 in /private/var/root/.local/lib/python3.7/site-packages (from trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (1.12.0)
Requirement already satisfied: pyotp==2.3.0 in /private/var/root/.local/lib/python3.7/site-packages (from trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (2.3.0)
Requirement already satisfied: requests<3.0.0,>=2.18.4 in /private/var/root/.local/lib/python3.7/site-packages (from trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (2.23.0)
Requirement already satisfied: pyaml==19.4.1 in /private/var/root/.local/lib/python3.7/site-packages (from trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (19.4.1)
Requirement already satisfied: six>=1.5 in /private/var/root/.local/lib/python3.7/site-packages (from python-dateutil->blobbycompanyconnect) (1.15.0)
Requirement already satisfied: importlib-metadata<2,>=0.23; python_version == "3.7" in /private/var/root/.local/lib/python3.7/site-packages (from argcomplete<2.0.0,>=1.6.0->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (1.7.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /private/var/root/.local/lib/python3.7/site-packages (from requests<3.0.0,>=2.18.4->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (1.25.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /private/var/root/.local/lib/python3.7/site-packages (from requests<3.0.0,>=2.18.4->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /private/var/root/.local/lib/python3.7/site-packages (from requests<3.0.0,>=2.18.4->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /private/var/root/.local/lib/python3.7/site-packages (from requests<3.0.0,>=2.18.4->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (2.10)
Requirement already satisfied: PyYAML in /private/var/root/.local/lib/python3.7/site-packages (from pyaml==19.4.1->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (5.3.1)
Requirement already satisfied: zipp>=0.5 in /private/var/root/.local/lib/python3.7/site-packages (from importlib-metadata<2,>=0.23; python_version == "3.7"->argcomplete<2.0.0,>=1.6.0->trovecompanyconnect<3.0,>=2.0->blobbycompanyconnect) (3.1.0)
You are using pip version 19.0.3, however version 20.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Error:-
$ blobbycompanyconnect
Traceback (most recent call last):
File "/usr/local/bin/blobbycompanyconnect", line 6, in <module>
from blobbycompanyconnect.cli import main
File "/Library/Python/2.7/site-packages/blobbycompanyconnect/cli.py", line 6, in <module>
from .companyconnect import get_cli_creds
File "/Library/Python/2.7/site-packages/blobbycompanyconnect/companyconnect.py", line 5, in <module>
from trovecompanyconnect.companyconnect_auth_api import companyconnectAuthApi, AppToApp, BOLTENV
ImportError: No module named trovecompanyconnect.companyconnect_auth_api
Your project runs on 2.7. I don't know if you use a virtual environment, maybe you should upgrade python there or on your IDE mostly on the right bottom you can see your python version check it.

Python3 import Error: No module named 'pytest'

I have installed pytest successfully,but import error occurs "ModuleNotFoundError: No module named 'pytest'".I can see pytest in my finder but it not in the "python3 -m pip list".How can I solve it?
HelendeMacBook-Pro:bin helendai$ pip3 install pytest
Collecting pytest
Using cached pytest-5.4.1-py3-none-any.whl (246 kB)
Requirement already satisfied: more-itertools>=4.0.0 in /usr/local/lib/python3.6/site-packages (from pytest) (8.2.0)
Requirement already satisfied: packaging in /usr/local/lib/python3.6/site-packages (from pytest) (20.3)
Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.6/site-packages (from pytest) (19.3.0)
Requirement already satisfied: pluggy<1.0,>=0.12 in /usr/local/lib/python3.6/site-packages (from pytest) (0.13.1)
Requirement already satisfied: py>=1.5.0 in /usr/local/lib/python3.6/site-packages (from pytest) (1.8.1)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/site-packages (from pytest) (0.1.9)
Requirement already satisfied: importlib-metadata>=0.12; python_version < "3.8" in /usr/local/lib/python3.6/site-packages (from pytest) (1.6.0)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.6/site-packages (from packaging->pytest) (2.4.7)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from packaging->pytest) (1.14.0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/site-packages (from importlib-metadata>=0.12; python_version < "3.8"->pytest) (3.1.0)
Installing collected packages: pytest
Successfully installed pytest-5.4.1
HelendeMacBook-Pro:bin helendai$ python3 -m pip list
Package Version
------------ ----------
certifi 2019.11.28
cffi 1.14.0
chardet 3.0.4
cryptography 2.8
idna 2.9
pip 20.0.2
pycparser 2.20
pyOpenSSL 19.1.0
PyYAML 5.3
requests 2.23.0
setuptools 41.2.0
six 1.14.0
urllib3 1.25.8
HelendeMacBook-Pro:bin helendai$ python3
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pytest'
enter image description here
perhaps you had installed multiple python on your computer, because the install logs show pytest is installed on python 3.6, but the python shell show your python version is 3.8.2

ImportError: cannot import name 'dispatcher' for Scrapy

I installed scrapy using pip install scrapy on Windows 10. It shows ImportError: cannot import name 'dispatcher'. I am using Python 3.5.
Help would be appreciated. Thank you.
Here is the complete trace:
"C:\Users\sameer\AppData\Local\Programs\Python\Python35\Scripts\scrapy.exe\__main__.py", line 5, in <module>
File "c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages\scrapy\cmdline.py", line 9, in <module>
from scrapy.crawler import CrawlerProcess
File "c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages\scrapy\crawler.py", line 15, in <module>
from scrapy.signalmanager import SignalManager
File "c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages\scrapy\signalmanager.py", line 2, in <module>
from pydispatch import dispatcher
ImportError: cannot import name 'dispatcher'
OUTPUT of pip install scrapy
Requirement already satisfied: scrapy in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (1.5.0)
Requirement already satisfied: cssselect>=0.9 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (1.0.3)
Requirement already satisfied: parsel>=1.1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (1.4.0)
Requirement already satisfied: w3lib>=1.17.0 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (1.19.0)
Requirement already satisfied: six>=1.5.2 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (1.11.0)
Requirement already satisfied: PyDispatcher>=2.0.5 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (2.0.5)
Requirement already satisfied: pyOpenSSL in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (18.0.0)
Requirement already satisfied: lxml in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (4.2.2)
Requirement already satisfied: queuelib in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (1.5.0)
Requirement already satisfied: service-identity in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (17.0.0)
Requirement already satisfied: Twisted>=13.1.0 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from scrapy) (18.4.0)
Requirement already satisfied: cryptography>=2.2.1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from pyOpenSSL->scrapy) (2.2.2)
Requirement already satisfied: pyasn1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from service-identity->scrapy) (0.4.3)
Requirement already satisfied: pyasn1-modules in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from service-identity->scrapy) (0.2.1)
Requirement already satisfied: attrs in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from service-identity->scrapy) (18.1.0)
Requirement already satisfied: zope.interface>=4.4.2 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from Twisted>=13.1.0->scrapy) (4.5.0)
Requirement already satisfied: constantly>=15.1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from Twisted>=13.1.0->scrapy) (15.1.0)
Requirement already satisfied: incremental>=16.10.1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from Twisted>=13.1.0->scrapy) (17.5.0)
Requirement already satisfied: Automat>=0.3.0 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from Twisted>=13.1.0->scrapy) (0.7.0)
Requirement already satisfied: hyperlink>=17.1.1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from Twisted>=13.1.0->scrapy) (18.0.0)
Requirement already satisfied: idna>=2.1 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from cryptography>=2.2.1->pyOpenSSL->scrapy) (2.7)
Requirement already satisfied: cffi>=1.7; platform_python_implementation != "PyPy" in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from cryptography>=2.2.1->pyOpenSSL->scrapy) (1.11.5)
Requirement already satisfied: asn1crypto>=0.21.0 in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from cryptography>=2.2.1->pyOpenSSL->scrapy) (0.24.0)
Requirement already satisfied: setuptools in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from zope.interface>=4.4.2->Twisted>=13.1.0->scrapy) (39.2.0)
Requirement already satisfied: pycparser in c:\users\sameer\appdata\local\programs\python\python35\lib\site-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=2.2.1->pyOpenSSL->scrapy) (2.18)
have you tried pip install dispatcher
edit:
when trying to install it myself, i've noticed some broken dependencies.
flask-babelex 0.9.3 requires speaklater>=1.2, which is not installed.
pyasn1-modules 0.2.1 has requirement pyasn1<0.5.0,>=0.4.1, but you'll have pyasn1 0.1.9 which is incompatible.
So I fixed the dependencies as written, first pip install speaklater,
then pip uninstall pyasn1 && pip install pyasn1
after all dependencies were met, scrapy worked fine.
Can you show the output of 'pip install scrapy'?
You need to make sure that you use pip for Python3, in case you also have Python2 installed. Then you should use: pip3 install PyDispatcher (currently at version 2.0.5). Then you import with:
from scrapy import signals
from scrapy.xlib.pydispatch import dispatcher
...
signal may or may not be optional, depending on what else you want to do.

google Colaboratory opencv xfeatures2d_SURF

!pip install opencv-python && pip install opencv-contrib-python
Requirement already satisfied: opencv-python in
/usr/local/lib/python3.6/dist-packages Requirement already satisfied:
numpy>=1.11.3 in /usr/local/lib/python3.6/dist-packages (from
opencv-python) Requirement already satisfied: opencv-contrib-python in
/usr/local/lib/python3.6/dist-packages Requirement already satisfied:
numpy>=1.11.3 in /usr/local/lib/python3.6/dist-packages (from
opencv-contrib-python)
import cv2
cv2.xfeatures2d_SURF
AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d_SURF'
Why does not it work?
xfeatures2d_SURF is not a proper function.
Try: cv2.xfeatures2d.SURF_create() to test your installation.
Here is an tutorial showing how to use SURF in python.

Resources