I'm quite new in python and faced this issue after the manual installation of the new jsonschema dependency.
$ python /var/www/html/graylog.py
Traceback (most recent call last):
File "/var/www/html/graylog.py", line 18, in <module>
from jsonschema import validate
ImportError: cannot import name 'validate'
Python version 3.6.8
This is the current pip list
Package Version
------------------ --------
attrs 19.3.0
certifi 2019.3.9
chardet 3.0.4
Click 7.0
configparser 5.0.0
Flask 1.0.2
Flask-WTF 0.14.2
grapi 0.1.4
idna 2.8
importlib-metadata 1.6.1
itsdangerous 1.1.0
Jinja2 2.10
jsonschema 3.2.0
M2Crypto 0.35.2
MarkupSafe 1.1.1
Nuitka 0.6.8.3
pip 20.1.1
prometheus-client 0.8.0
PyMySQL 0.9.3
pyrsistent 0.16.0
PySimpleGUI 3.29.0
requests 2.21.0
setuptools 39.2.0
six 1.15.0
urllib3 1.24.1
virtualenv 16.4.3
Werkzeug 0.15.1
WTForms 2.2.1
zipp 3.1.0
Try to update the jsonSchema version that often solves the error especially if it's been installed manually
pip install --upgrade jsonschema
It may also be that the python that you are using in your environment may point to a different version that does not contain the jsonSchema module. Try
python3 /var/www/html/graylog.py
Related
I am try to implement keyring on a windows system to manage database passwords for connection strings in pyodbc and sqlalchemy. I have tried to ensure the relevant packages from the NameError(s) thrown are installed.
Reason for manually setting the backend in keyring on windows
Here is the code I ran:`
from keyring.backends import Windows
import keyring
keyring.set_keyring(Windows.WinVaultKeyring())
keyring.get_password("Service", "Username")
Here are the errors thrown:
Traceback (most recent call last):
File ".\Python310\lib\site-packages\keyring\backends\Windows.py", line 109, in _get_password
res = win32cred.CredRead(
NameError: name 'win32cred' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\Python310\lib\site-packages\keyring\core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File ".\Python310\lib\site-packages\keyring\backends\Windows.py", line 99, in get_password
res = self._get_password(service)
File ".\Python310lib\site-packages\keyring\backends\Windows.py", line 112, in _get_password
except pywintypes.error as e:
NameError: name 'pywintypes' is not defined
Installed packages are listed:
Package
Version
astroid
2.9.3
backcall
0.2.0
certifi
2021.10.8
cffi
1.15.0
charset-normalizer
2.0.12
cloudpickle
2.1.0
colorama
0.4.4
comtypes
1.1.11
cryptography
37.0.2
dask
2022.6.1
executing
0.8.3
fsspec
2022.5.0
greenlet
1.1.2
idna
3.3
ipython-genutils
0.2.0
isort
5.10.1
keyring
23.6.0
lazy-object-proxy
1.7.1
locket
1.0.0
mccabe
0.6.1
mistune
0.8.4
MouseInfo
0.1.3
numpy
1.22.3
opencv-python
4.5.5.64
packaging
21.3
pandas
1.4.1
partd
1.2.0
pickleshare
0.7.5
Pillow
9.1.1
pip
22.1.2
platformdirs
2.5.1
pure-eval
0.2.2
PyAutoGUI
0.9.53
pycparser
2.21
PyGetWindow
0.0.9
pylint
2.12.2
PyMsgBox
1.0.9
pyodbc
4.0.32
pyparsing
3.0.7
pyperclip
1.8.2
PyQt6
6.3.1
PyQt6-Qt6
6.3.1
PyQt6-sip
13.4.0
PyRect
0.2.0
PyScreeze
0.1.28
pytesseract
0.3.9
python-bidi
0.4.2
python-dateutil
2.8.2
pytweening
1.0.4
pytz
2022.1
PyWavelets
1.3.0
pywin32
303
pywin32-ctypes
0.2.0
pywinauto
0.6.8
PyYAML
6
requests
2.27.1
scipy
1.8.0
Send2Trash
1.8.0
setuptools
58.1.0
six
1.16.0
SQLAlchemy
1.4.39
sudo
1.0.0
tifffile
2022.3.16
toml
0.10.2
toolz
0.11.2
torch
1.11.0
torchaudio
0.11.0
torchvision
0.12.0
traitlets
5.1.1
typing_extensions
4.1.1
urllib3
1.26.9
wcwidth
0.2.5
webencodings
0.5.1
wrapt
1.13.3
This was an issue with extra python installations on my device.
I fixed this issue by deleting an extra set of python installations on my computer.
Create venv without admin access python
import keyring
keyring.set_keyring(Windows.WinVaultKeyring())
keyring.get_password("Service", "Username")
keyring.set_password("TestService","TestUser", "TestPassword")
keyring.get_password("TestService", "TestUser")
Prints:
'TestPassword'
Edit, this also fixes the need to set the default keyring.
I can omit: keyring.set_keyring(Windows.WinVaultKeyring())
I am using flask to create user login and I encounter this error when I try to run my program. As you can see I already have email-validtaor installed, so why is it still telling me to install it?
Exception: Install 'email_validator' for email validation support.
This is my pip list that show email-validator installed.
Peters-Air:~ peterkogolo$ pip list
Package Version
backports.entry-points-selectable 1.1.0
bcrypt 3.2.0
blinker 1.4
certifi 2021.10.8
cffi 1.15.0
click 8.0.3
distlib 0.3.3
dnspython 2.2.1
email-validator 1.2.1
filelock 3.3.1
Flask 2.0.2
Flask-Bcrypt 1.0.1
Flask-Login 0.5.0
Flask-Mail 0.9.1
Flask-SQLAlchemy 2.5.1
greenlet 1.1.2
idna 3.3
itsdangerous 2.0.1
Jinja2 3.0.2
MarkupSafe 2.0.1
pip 21.3.1
pipenv 2021.5.29
platformdirs 2.4.0
pycparser 2.21
setuptools 57.4.0
six 1.16.0
SQLAlchemy 1.4.26
virtualenv 20.9.0
virtualenv-clone 0.5.7
Werkzeug 2.0.2
WTForms 3.0.0
I am trying to install zappa for my Django project with the pip install zappa command.
For some reason I am getting the error message:
Collecting kappa==0.6.0
Using cached kappa-0.6.0.tar.gz (29 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
python setup.py egg_info did not run successfully.
exit code: 1
[10 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\F\AppData\Local\Temp\pip-install-0z9s37z_\kappa_3e41fa04962841afbbe1bfd266342d06\setup.py", line 54, in <module>
run_setup()
File "C:\Users\F\AppData\Local\Temp\pip-install-0z9s37z_\kappa_3e41fa04962841afbbe1bfd266342d06\setup.py", line 22, in run_setup
long_description=open_file('README.rst').read(),
File "C:\users\F\appdata\local\programs\python\python310\lib\encodings\cp1253.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9c in position 2341: character maps to <undefined>
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
Encountered error while generating package metadata.
See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
I am using Windows 10 and Python 3.10.1 .
[Edit] my pip list results are:
(venv) C:\Users\F>pip list
Package Version
------------------------- ---------
argcomplete 2.0.0
arrow 1.2.1
asgiref 3.5.0
atomicwrites 1.4.0
attrs 21.4.0
awsebcli 3.20.3
binaryornot 0.4.4
boto3 1.21.19
botocore 1.24.19
cement 2.8.2
certifi 2021.10.8
cffi 1.15.0
cfn-flip 1.3.0
chardet 4.0.0
charset-normalizer 2.0.12
click 8.0.4
colorama 0.4.3
cookiecutter 1.7.3
coverage 6.3.2
cryptography 36.0.1
defusedxml 0.7.1
distlib 0.3.4
Django 4.0.3
django-cors-headers 3.11.0
django-countries 7.2.1
django-filter 21.1
django-modeladmin-reorder 0.3.1
django-simple-history 3.0.0
django-tailwind 3.0.1
djangorestframework 3.13.1
djangorestframework-csv 2.1.1
drf-extensions 0.7.1
drf-spectacular 0.21.2
drf-spectacular-sidecar 2022.3.14
durationpy 0.5
factory-boy 3.2.1
Faker 13.3.2
filelock 3.4.2
future 0.18.2
hjson 3.0.2
idna 3.3
inflection 0.5.1
iniconfig 1.1.1
isodate 0.6.1
Jinja2 3.1.2
jinja2-time 0.2.0
jmespath 0.10.0
jsonschema 4.4.0
jwt 1.3.1
Markdown 3.3.6
MarkupSafe 2.0.1
mixer 7.2.2
names-dataset 3.0.2
npm 0.1.1
oauthlib 3.2.0
optional-django 0.1.0
packaging 21.3
pathspec 0.9.0
pendulum 2.1.2
pip 22.0.4
pipenv 2022.1.8
placebo 0.9.0
platformdirs 2.5.2
pluggy 1.0.0
poyo 0.5.0
psycopg2-binary 2.9.3
py 1.11.0
pycountry 22.3.5
pycparser 2.21
Pygments 2.11.2
PyJWT 2.3.0
pymongo 3.11.1
PyPardot 0.1
PyPardotSF 0.1.0
pyparsing 3.0.7
pypiwin32 223
pyrsistent 0.18.1
pytest 7.1.1
pytest-cov 3.0.0
pytest-django 4.5.2
python-dateutil 2.8.2
python-slugify 6.1.1
python3-openid 3.2.0
pytz 2021.3
pytzdata 2020.1
pywin32 303
PyYAML 6.0
requests 2.27.1
requests-oauthlib 1.3.1
s3transfer 0.5.2
semantic-version 2.8.5
setuptools 62.1.0
six 1.16.0
social-auth-app-django 5.0.0
social-auth-core 4.2.0
sqlparse 0.4.2
termcolor 1.1.0
text-unidecode 1.3
toml 0.10.2
tomli 2.0.1
tqdm 4.63.0
troposphere 3.2.2
tzdata 2021.5
unicodecsv 0.14.1
Unidecode 1.3.4
uritemplate 4.1.1
urllib3 1.26.8
virtualenv 20.14.1
virtualenv-clone 0.5.7
wcwidth 0.1.9
Werkzeug 2.0.3
wheel 0.37.1
wsgi-request-logger 0.4.6
xmltodict 0.12.0
With pip pip -V being pip 22.0.4 from C:\Users\F\...\pip (python 3.10)
I haven't found any similar issues online so I could use some help to solve it.
Trying to read data from one of my google spreadsheet.
I've got the JSON file from google, trying to put it as a string in the script.
this is what I have so far:
import json
import os
from google.oauth2 import service_account
from google.cloud import translate
.
.
.
json_as_string = """........"""
info = json.loads(os.environ[json_as_string])
creds = service_account.Credentials.from_service_account_info(info)
# Instantiates a client
translate_client = translate.Client(credentials=creds)
# credentials = ServiceAccountCredentials.from_json_keyfile_name("SendMyCardCheckUP-2e671ca3c2eb.json", scope)
client = gspread.authorize(credentials)
sheet = client.open("file_name").sheet1
this is what I get back :
from google.oauth2 import service_account
ModuleNotFoundError: No module named 'google'
Already tried through cmd -
pip install -t lib google-auth google-auth-httplib2 google-api-python-client --upgrade
pip install --upgrade google-api-python-client
For some reason, the import of the "google" package doesn't work, any ideas?
EDIT:
pip list:
Package Version
------------------------ ----------
altgraph 0.16.1
asn1crypto 0.24.0
attrs 19.1.0
beautifulsoup4 4.8.0
cachetools 3.1.0
certifi 2018.11.29
cffi 1.12.3
chardet 3.0.4
cryptography 2.6.1
cycler 0.10.0
decorator 4.4.0
future 0.17.1
google 2.0.2
google-api-core 1.14.2
google-api-python-client 1.7.11
google-auth 1.6.3
google-auth-httplib2 0.0.3
google-auth-oauthlib 0.4.0
google-cloud 0.34.0
google-cloud-core 1.0.3
google-cloud-storage 1.18.0
google-cloud-translate 1.6.0
google-oauth 1.0.1
google-resumable-media 0.3.2
googleapis-common-protos 1.6.0
grpcio 1.23.0
gspread 3.1.0
httplib2 0.12.3
idna 2.8
ipython-genutils 0.2.0
jsonschema 3.0.1
jupyter-core 4.4.0
kiwisolver 1.1.0
macholib 1.11
matplotlib 3.0.3
nbformat 4.4.0
numpy 1.16.3
oauth2client 4.1.3
oauthlib 3.0.1
opencv-python 4.1.0.25
pefile 2018.8.8
pip 19.2.2
plotly 3.8.1
protobuf 3.8.0rc1
py 1.8.0
pyasn1 0.4.5
pyasn1-modules 0.2.5
pycparser 2.19
pygame 1.9.6
PyInstaller 3.4
pyOpenSSL 19.0.0
pyparsing 2.4.0
pyrsistent 0.15.1
python-dateutil 2.8.0
python-pygaze 0.6.0a25
pytz 2019.1
pywin32-ctypes 0.2.0
requests 2.22.0
requests-oauthlib 1.2.0
retrying 1.3.3
rsa 4.0
selenium 3.141.0
setuptools 39.0.1
six 1.12.0
soupsieve 1.9.2
traitlets 4.3.2
uritemplate 3.0.0
urllib3 1.24.1
FOUND IT -
pip install google_oauth2_tool
will make the service account work.
pip install google-cloud-storage
will make from google.cloud work
pip install google.cloud.translate
Getting the following stack trace from line:
zipline/zipline/__init__.py", line 17, in <module>
import numpy as np
ImportError: No module named 'numpy'
however, when I check pip list
pip list | grep numpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
numpy 1.16.6
This all occurs after I clone into the Quantopian/Zipline Github Repo.
I opened an issue on github, after this edit I'll search SO for anything obvious I missed.
Environment
WSL Ubunut Subsystem
Pyhon 3.5.5
Bitness: 64
installed dependencies via
sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev
Pip list
alembic 1.4.2
asn1crypto 0.24.0
bcolz 0.12.1
Bottleneck 1.3.2
certifi 2019.11.28
chardet 3.0.4
click 7.1.1
contextlib2 0.6.0.post1
cycler 0.10.0
cyordereddict 1.0.0
Cython 0.29.15
decorator 4.4.2
empyrical 0.5.3
enum34 1.1.6
funcsigs 1.0.2
idna 2.6
intervaltree 3.0.2
ipaddress 1.0.17
itable 0.0.1
keyring 10.6.0
Logbook 1.5.3
lru-dict 1.1.6
lxml 4.5.0
Mako 1.1.2
MarkupSafe 1.1.1
matplotlib 2.2.4
mercurial 4.5.3
mock 3.0.5
multipledispatch 0.6.0
networkx 1.11
numexpr 2.7.1
numpy 1.16.6
pandas 0.22.0
pandas-datareader 0.8.1
patsy 0.5.1
pinkfish 0.5.1
pip 19.3.1
pycrypto 2.6.1
pygobject 3.26.1
python-dateutil 2.8.1
python-editor 1.0.4
pytz 2019.3
pyxdg 0.25
requests 2.22.0
requests-file 1.4.3
scipy 1.2.2
SecretStorage 2.3.1
setuptools 39.0.1
six 1.14.0
sortedcontainers 2.1.0
SQLAlchemy 1.3.15
statsmodels 0.11.0
tables 3.5.2
toolz 0.10.0
trading-calendars 1.11.5
urllib3 1.25.7
wheel 0.30.0
zipline 1.3.0
WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Update
running as a script, sudo python test.py returns
File "test.py", line 1, in <module>
import zipline
File "../zipline/zipline/__init__.py", line 29, in <module>
from .utils.run_algo import run_algorithm
File "../zipline/zipline/utils/run_algo.py", line 17, in <module>
from zipline.data import bundles
File "../zipline/zipline/data/bundles/__init__.py", line 2, in <module>
from . import quandl # noqa
File "../zipline/zipline/data/bundles/quandl.py", line 17, in <module>
from . import core as bundles
File "../zipline/zipline/data/bundles/core.py", line 14, in <module>
from ..adjustments import SQLiteAdjustmentReader, SQLiteAdjustmentWriter
File "../zipline/zipline/data/adjustments.py", line 24, in <module>
from ._adjustments import load_adjustments_from_sqlite
ImportError: No module named _adjustments
The issue arose due to the presence of multiple versions of python. Using the python -m pip install <packages> command inside of the zipline/zipline repo, I was able to successful execute import zipline inside a python shell