aws git-remote-codecommit operation error (GRC) - python-3.x

I hit this error when using git with a remote codecommit repo using GRC protocol.
git fetch
Traceback (most recent call last):
File "/home/meh/.local/bin/git-remote-codecommit", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3095, in <module>
#_call_aside
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3079, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3108, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 570, in _build_master
ws.require(__requires__)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 888, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 774, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'jmespath<2.0.0,>=0.7.1' distribution was not found and is required by botocore

Answering my own question in case other hit this issue.
I'm using oracle linux 8 install atm, and installed python3 and and awscli + boto from an rpm.
for me the fix was to install jmespath from yum. It's not obvious at first but this is part of the python package family. to fix the issue you need to install the additional python3-jmespath package.
Example:
sudo yum install python3-jmespath.noarch

Related

problems installing sqlite and python on freebsd

This is driving me crazy! Any help you can provide will be most welcome!
I have a python3/sqlite application (running in a virtual environment) that is working fine on debian. I need to install it on freebsd (running in a virtual environment). I have installed python3 and sqlite (I can open a .sqlite file from the command line).
When I try to run the python script, I get the following error:
(venv) [jordan#webServer ~/crons/powerwall]$ python3 main.py
Traceback (most recent call last):
File "/usr/home/jordan/crons/powerwall/main.py", line 78, in <module>
run()
File "/usr/home/jordan/crons/powerwall/main.py", line 33, in run
database.load_db(config_mgr=config)
File "/usr/home/jordan/crons/powerwall/database.py", line 108, in load_db
db = PowerWallDb(cfg_mgr=config_mgr)
File "/usr/home/jordan/crons/powerwall/database.py", line 94, in __init__
super().__init__(cfg_mgr=cfg_mgr, section=section)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 77, in __init__
self._connect_sqlite(self.sqlite_file, check_same_thread=False)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 99, in _connect_sqlite
self._connect_uri(uri, **kwargs)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 95, in _connect_uri
self.connection = sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(uri, **kwargs)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 1105, in connectionForURI
conn = connCls.connectionFromURI(uri)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 154, in connectionFromURI
return cls._connectionFromParams(*cls._parseURI(uri))
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 122, in _connectionFromParams
return cls(filename=path, **args)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 64, in __init__
raise ImportError(
ImportError: Cannot find an SQLite driver, tried supersqlite,pysqlite2,sqlite3,sqlite
Exception ignored in: <function DBAPI.__del__ at 0x8029c1310>
Traceback (most recent call last):
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 704, in __del__
self.close()
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 217, in close
if self._memory:
AttributeError: 'SQLiteConnection' object has no attribute '_memory'
You have to install py-sqlite3 which is the "Standard Python binding to the SQLite3 library"
Install From Ports:
cd /usr/ports/databases/py-sqlite3/ && make install clean
Install From pkg:
pkg install databases/py-sqlite3
Basically, it looks like the standard Python bindings for SQLite is a separate package on FreeBSD (perhaps, on all *nix/*BSD). So, in general, there are three components, which you need, Python, SQLite (this one may not be actually necessary for Python) AND the standard Python bindings for SQLite. I have not worked with FreeBSD, but based on Googling, have you tried installing this https://pkgs.org/download/py39-sqlite3 maybe?

when running virtualenv command on terminal

Thank you for your time.
I installed virtualenv on my mac using pip, but when I ran virtualenv env, it showed an error:
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 6, in
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 3241, in
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 583, in _build_master
ws.require(requires)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'importlib-resources>=1.0' distribution was not found and is required by virtualenv
Please help. I installed the latest packaghes of importlib but it still doesn't work.
Your stack shows 2.7 python.
your tag question as python-3.x
You indicated that you already have importlib.
But error is about importlib-resources.
Try to import importlib_resources:
importlib_resources is a backport of Python 3.9’s standard library importlib.resources module for Python 2.7, and 3.5 through 3.8. Users of Python 3.9 and beyond are encouraged to use the standard library module. Developers looking for detailed API descriptions should refer to the Python 3.9 standard library documentation.

pyenv BUILD FAILED while trying (pyenv install -v 3.9.0) on wsl2 ubuntu 20.04

SOLVED: the solution was I needed zlib1g-dev
This is the error pyenv produces
Traceback (most recent call last):
File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 568, in _get_data
File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 206, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 147, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "<frozen zipimport>", line 241, in load_module
File "<frozen zipimport>", line 709, in _get_module_code
File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
Traceback (most recent call last):
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__init__.py", line 210, in _main
return _bootstrap(
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__init__.py", line 129, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__init__.py", line 38, in _run_pip
return subprocess.run([sys.executable, "-c", code], check=True).returncode
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/python-build.20201212114143.1082/Python-3.9.0/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpk898xfhs/setuptools-49.2.1-py3-none-any.whl\', \'/tmp/tmpk898xfhs/pip-20.2.3-py2.py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpk898xfhs\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [Makefile:1254: install] Error 1
I have found nothing on this when googling and have no idea what is going on.
the steps that I have done are, first installing the pyenv installer and running that script then trying to run (pyenv install -v 3.9.0)
the system does have python3.8 installed and pyenv does seem to know about it
but it still will not let me install 3.9.0
EDIT: I should also throw in that in order to let pyenv know about the system version of python I did this (sudo ln -s /usr/bin/python3 /usr/bin/python).
Another thing is I also tried installing 3.9.0 with a tool called asdf and that resulted in the same error
EDIT2: It seems like im missing zlib from the traceback but Im on ubuntu and do have zlib1g installed and from what I looked up thats what zlib is on ubuntu 20.04 im going to try and find more info on the zlib and see if I need to install something else
I had a similar problem trying to install Python 3.8 with asdf (which uses the same backend as pyenv) on WSL2/Ubutnu18, and installing zlib1g-dev was not enough to solve it as stated by the question's author.
Therefore, as a more general solution, I have found that installing all dependencies recommended by pyenv for Ubuntu did solve the problem for asdf (and I suspect for pyenv as well). The dependencies for different OS can be found here: https://github.com/pyenv/pyenv/wiki#suggested-build-environment
I hope this is useful for others!
PS: This resource might be useful as well for similar issues: https://github.com/pyenv/pyenv/wiki/Common-build-problems

Cannot use most python apps after updating to Ubuntu 18.04

After updating to Ubuntu 18.04 LTS I can no longer use most Python apps including pip (to install or uninstall). I get the following error in command-line:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 572, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2755, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2408, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2414, in resolve
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
After Googling the errors it appears that the version of pyopenssl is out of date, but I've tried to manually download an installpyopenssl18 through a TGZ file or through easy_install and neither have worked.
I cannot install/uninstall via pip because I get the above error. Any suggestions? I'd like to avoid having to reinstall Python or even the OS itself.
After trying the manual install of pyopenssl 18 again I noticed the path it was installing to: /usr/local/lib/python2.7/dist-packages
So I went digging in that directory and saw a folder called:
OpenSSL
which was referenced in the error. I renamed this folder and re-installed pyopenssl and the error is cleared. I don't have any issues accessing HTTPS sites so it is possible this is a deprecated module replaced by pyOpenSSL?

Tensorflow breaks pip on anaconda, windows os

Last version of anaconda, windows 10, python 3.6.
Installing tensorflow seems to break pip.
>conda create -n py6 python=3.6
>activate py6
>conda install tensorflow
>pip install tweepy
Collecting tweepy
Exception:
Traceback (most recent call last):
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 731, in __init__
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
Use of tweepy is just an example, pip cannot install any package.
The same happens when installing tensorflow using pip, and when using a python 3.5 virtual environment.
Probably this is due to some package update gone wrong, and it will be fixed in the next update.
Meanwhile, any fix or any careful selection of working version numbers is welcome.
This issues is reported in the following ticket : https://github.com/tensorflow/tensorboard/issues/588
To solve this, you need to repair html5lib.
Or alternatively,
you can make use of anaconda to re-install
conda install -c anaconda html5lib

Resources