Updated AWS CLI for EC2 via Ansible throws boto errors - python

I'm seeing an odd issue where after updating the AWS CLI from 1.10.1 to 1.10.60, running ec2 commands through Ansible no longer works.
i.e., running:
local_action: "shell AWS_PROFILE=dev-aws aws ec2 describe-instances --debug --filters 'Name=instance-state-name,Values=running' 'Name=tag:Role,Values=ms_bastion'"
... through Ansible throws this stack trace:
File \"/usr/local/bin/aws\", line 23, in main
return awscli.clidriver.main()
File \"/usr/local/lib/python2.7/site-packages/awscli/clidriver.py\", line 49, in main
driver = create_clidriver()
File \"/usr/local/lib/python2.7/site-packages/awscli/clidriver.py\", line 58, in create_clidriver
event_hooks=emitter)
File \"/usr/local/lib/python2.7/site-packages/awscli/plugin.py\", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File \"/usr/local/lib/python2.7/site-packages/awscli/plugin.py\", line 61, in _import_plugins
module = __import__(path, fromlist=[module])
File \"/usr/local/lib/python2.7/site-packages/awscli/handlers.py\", line 66, in <module>
from awscli.customizations.s3.s3 import s3_plugin_initialize
File \"/usr/local/lib/python2.7/site-packages/awscli/customizations/s3/s3.py\", line 15, in <module>
from awscli.customizations.s3.subcommands import ListCommand, WebsiteCommand, \\
File \"/usr/local/lib/python2.7/site-packages/awscli/customizations/s3/subcommands.py\", line 24, in <module>
from awscli.customizations.s3.fileinfobuilder import FileInfoBuilder
File \"/usr/local/lib/python2.7/site-packages/awscli/customizations/s3/fileinfobuilder.py\", line 13, in <module>
from awscli.customizations.s3.fileinfo import FileInfo
File \"/usr/local/lib/python2.7/site-packages/awscli/customizations/s3/fileinfo.py\", line 9, in <module>
from botocore.compat import MD5_AVAILABLE
ImportError: cannot import name MD5_AVAILABLE

Related

GOT TypeError: deprecated() got an unexpected keyword argument 'name' in boto3

Boto3 was running successfully the day before but when i ran today i am getting these errors
import boto3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/root1/.local/lib/python3.10/site-packages/boto3/__init__.py", line 16, in <module>
from boto3.session import Session
File "/home/root1/.local/lib/python3.10/site-packages/boto3/session.py", line 17, in <module>
import botocore.session
File "/home/root1/.local/lib/python3.10/site-packages/botocore/session.py", line 29, in <module>
import botocore.credentials
File "/home/root1/.local/lib/python3.10/site-packages/botocore/credentials.py", line 35, in <module>
from botocore.config import Config
File "/home/root1/.local/lib/python3.10/site-packages/botocore/config.py", line 16, in <module>
from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
File "/home/root1/.local/lib/python3.10/site-packages/botocore/endpoint.py", line 24, in <module>
from botocore.awsrequest import create_request_object
File "/home/root1/.local/lib/python3.10/site-packages/botocore/awsrequest.py", line 24, in <module>
import botocore.utils
File "/home/root1/.local/lib/python3.10/site-packages/botocore/utils.py", line 32, in <module>
import botocore.httpsession
File "/home/root1/.local/lib/python3.10/site-packages/botocore/httpsession.py", line 28, in <module>
from urllib3.contrib.pyopenssl import orig_util_SSLContext as SSLContext
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 50, in <module>
import OpenSSL.SSL
File "/home/root1/.local/lib/python3.10/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import SSL, crypto
File "/home/root1/.local/lib/python3.10/site-packages/OpenSSL/SSL.py", line 19, in <module>
from OpenSSL.crypto import (
File "/home/root1/.local/lib/python3.10/site-packages/OpenSSL/crypto.py", line 3224, in <module>
utils.deprecated(
TypeError: deprecated() got an unexpected keyword argument 'name'
i tried uninstalling and reinstalling also tried out installing specific version
still getting an error
i am using it on ubuntu 22.0
the python version i am running
Python 3.10.6

Flask, wsgi and deploy

(pardon my english)
Hello,
I've a problem for a deploy on a gandi server.
After a git push on a gandi server, I'm proceeding a deploy :
ssh [url] deploy default.git
I obtain an "Internal Error Server".
My log/www/uwsgi.log said :
Traceback (most recent call last):
File "/srv/data/web/vhosts/default/wsgi.py", line 1, in <module>
from run import app as application
File "./run.py", line 1, in <module>
from app import app as application
File "./app/__init__.py", line 1, in <module>
from flask import Flask
File "/srv/data/web/vhosts/default/local/lib/python3.6/site-packages/flask/__init__.py", line 19, in <module>
from jinja2 import Markup, escape
File "/srv/data/web/vhosts/default/local/lib/python3.6/site-packages/jinja2/__init__.py", line 82, in <module>
_patch_async()
File "/srv/data/web/vhosts/default/local/lib/python3.6/site-packages/jinja2/__init__.py", line 78, in _patch_async
from jinja2.asyncsupport import patch_all
File "/srv/data/web/vhosts/default/local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 13, in <module>
import asyncio
File "/opt/python-3.6/usr/lib/python3.6/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/python-3.6/usr/lib/python3.6/asyncio/base_events.py", line 17, in <module>
import concurrent.futures
File "/opt/python-3.6/usr/lib/python3.6/concurrent/futures/__init__.py", line 17, in <module>
from concurrent.futures.process import ProcessPoolExecutor
File "/opt/python-3.6/usr/lib/python3.6/concurrent/futures/process.py", line 55, in <module>
from multiprocessing.connection import wait
File "/opt/python-3.6/usr/lib/python3.6/multiprocessing/connection.py", line 23, in <module>
from . import util
File "/opt/python-3.6/usr/lib/python3.6/multiprocessing/util.py", line 17, in <module>
from subprocess import _args_from_interpreter_flags
File "/opt/python-3.6/usr/lib/python3.6/subprocess.py", line 136, in <module>
import _posixsubprocess
ImportError: /srv/data/web/vhosts/default/local/lib/python3.6/lib-dynload/_posixsubprocess.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _Py_set_inheritable_async_safe
I have not idea how can I solve this problem... ?
Anyone understand this problem ? Thank you

python fabric execute error

I execute fabric with both fab.exe and run python script directly.
But it shows error.
My PC is Windows 7, Python 2.7.13
Traceback (most recent call last):
File "C:\fabric_test.py", line 3, in <module>
from fabric.api import run,env,execute,task
File "C:\Python27\lib\site-packages\fabric\api.py", line 10, in <module>
from fabric.context_managers import (cd, hide, settings, show, path, prefix,
File "C:\Python27\lib\site-packages\fabric\context_managers.py", line 41, in <module>
from fabric.state import output, win32, connections, env
File "C:\Python27\lib\site-packages\fabric\state.py", line 9, in <module>
from fabric.network import HostConnectionCache, ssh
File "C:\Python27\lib\site-packages\fabric\network.py", line 24, in <module>
import paramiko as ssh
File "C:\Python27\lib\site-packages\paramiko\__init__.py", line 31, in <module>
from paramiko.transport import SecurityOptions, Transport
File "C:\Python27\lib\site-packages\paramiko\transport.py", line 56, in <module>
from paramiko.dsskey import DSSKey
File "C:\Python27\lib\site-packages\paramiko\dsskey.py", line 27, in <module>
from cryptography.hazmat.primitives.asymmetric.utils import (
File "C:\Python27\lib\site-packages\cryptography\hazmat\primitives\asymmetric\utils.py", line 9, in <module>
from asn1crypto.algos import DSASignature
File "C:\Python27\lib\site-packages\asn1crypto\algos.py", line 23, in <module>
from ._int import fill_width
File "C:\Python27\lib\site-packages\asn1crypto\_int.py", line 56, in <module>
from ._perf._big_num_ctypes import libcrypto
File "C:\Python27\lib\site-packages\asn1crypto\_perf\_big_num_ctypes.py", line 31, in <module>
libcrypto_path = find_library('crypto')
File "C:\Python27\lib\ctypes\util.py", line 53, in find_library
fname = os.path.join(directory, name)
File "C:\Python27\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbc in position 21: ordinal not in range(128)
what's the problem?
I hack the C:\Python27\lib\ntpath.py file.
add this source code to header of that file. (17 line)
reload(sys)
sys.setdefaultencoding('euc-kr')
then, error disappear. fabric works fine.
but i don't know reason.
what's the problem in my pc?
I want solve this problem without hack.

What does this capistrano error mean when doing an AWS file fetch via cap tasks?

In my deploy/development.rb, I have the following line:-
set :env_path, 's3api get-object --bucket <bucket_name> --key <file_name> <file_name>'
In my cap file, I have the following task defined:
task :download_configs do
on roles(:all) do
within release_path do
execute :aws, "#{fetch(:env_path)}"
end
end
# on roles(:db) do
# within release_path do
# execute :aws, "#{fetch(:env_path)}"
# end
# end
end
But on cap deploy,I am seeing the following errors:-
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ubuntu#54.213.226.117: aws exit status: 1
aws stdout: Traceback (most recent call last):
File "/usr/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/share/awscli/awscli/clidriver.py", line 30, in <module>
from awscli.help import ProviderHelpCommand
File "/usr/share/awscli/awscli/help.py", line 20, in <module>
from docutils.core import publish_string
File "/usr/lib/python3/dist-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/usr/lib/python3/dist-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/usr/lib/python3/dist-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/usr/lib/python3/dist-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/usr/lib/python3/dist-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/usr/lib/python3.4/locale.py", line 556, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib/python3.4/locale.py", line 484, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
aws stderr: Nothing written
SSHKit::Command::Failed: aws exit status: 1
aws stdout: Traceback (most recent call last):
File "/usr/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/share/awscli/awscli/clidriver.py", line 30, in <module>
from awscli.help import ProviderHelpCommand
File "/usr/share/awscli/awscli/help.py", line 20, in <module>
from docutils.core import publish_string
File "/usr/lib/python3/dist-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/usr/lib/python3/dist-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/usr/lib/python3/dist-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/usr/lib/python3/dist-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/usr/lib/python3/dist-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/usr/lib/python3.4/locale.py", line 556, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib/python3.4/locale.py", line 484, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
aws stderr: Nothing written
Please help me identify what is going wrong here!
Shot in the dark (I'm not a Python dev), but you might be able add the following to deploy.rb:
set :default_env, {
'LANG' => 'en_US.UTF-8'
}
Derived mostly from https://github.com/matplotlib/matplotlib/issues/5420#issuecomment-154454607
I would check to see if you can run the command manually on the server. If you cannot, then figure out how to without Capistrano. If you can, perhaps see if there is some configuration in .bashrc or .bash_profile that can be added to the Capistrano config.

/gevent/hub.py: except Exception, ex: SyntaxError

Traceback (most recent call last):
File "main.py", line 4, in <module>
from bot import bot
File "/root/musicbot/bot.py", line 7, in <module>
from database import db, text_search
File "/root/musicbot/database.py", line 2, in <module>
import pymongo
File "/usr/local/lib/python3.5/site-packages/pymongo/__init__.py", line 92, in <module>
from pymongo.connection import Connection
File "/usr/local/lib/python3.5/site-packages/pymongo/connection.py", line 39, in <module>
from pymongo.mongo_client import MongoClient
File "/usr/local/lib/python3.5/site-packages/pymongo/mongo_client.py", line 46, in <module>
from pymongo import (auth,
File "/usr/local/lib/python3.5/site-packages/pymongo/pool.py", line 22, in <module>
from pymongo import thread_util
File "/usr/local/lib/python3.5/site-packages/pymongo/thread_util.py", line 31, in <module>
from gevent.lock import BoundedSemaphore as GeventBoundedSemaphore
File "/usr/local/lib/python3.5/site-packages/gevent/__init__.py", line 36, in <module>
from gevent.hub import get_hub, iwait, wait
File "/usr/local/lib/python3.5/site-packages/gevent/hub.py", line 282
except Exception, ex:
^
SyntaxError: invalid syntax
You are using a Python package which is for Python 2.x and uses old Exception syntax (gevent.hub).
You need to upgrade the violating module to Python 3.x compatible version.
If this is not possible then you need to deploy your application on Python 2.x.

Categories