az login command failure - azure

Trying to set up Azure CLI on my Kali Linux. This is the version of kali.
kali#kali:~$ uname -a
Linux kali 5.5.0-kali2-amd64 #1 SMP Debian
5.5.17-1kali1 (2020-04-21) x86_64 GNU/Linux
After installation, when I run az login, it takes me to the browser where I enter required credentials that are accepted, and the browser then shows following message.
You have logged into Microsoft Azure!
However, in the shell window, it shows the following error.
kali#kali:~$ az login
You have logged in. Now let us find all the subscriptions to which you have access...
The command failed with an unexpected error. Here is the traceback:
'SubscriptionClient' object has no attribute 'config'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/knack/cli.py", line 215, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/_init_.py", line 654, in execute
raise ex
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/_init_.py", line 718, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/_init_.py", line 711, in _run_job
six.reraise(*sys.exc_info())
File "/usr/lib/python3/dist-packages/six.py", line 703, in reraise
raise value
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/_init_.py", line 688, in _run_job
result = cmd_copy(params)
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/_init.py", line 325, in __call_
return self.handler(*args, **kwargs)
File "/usr/lib/python3/dist-packages/azure/cli/core/_init_.py", line 782, in default_command_handler
return op(**command_args)
File "/usr/lib/python3/dist-packages/azure/cli/command_modules/profile/custom.py", line 152, in login
subscriptions = profile.find_subscriptions_on_login(
File "/usr/lib/python3/dist-packages/azure/cli/core/_profile.py", line 195, in find_subscriptions_on_login
subscriptions = subscription_finder.find_through_authorization_code_flow(
File "/usr/lib/python3/dist-packages/azure/cli/core/_profile.py", line 849, in find_through_authorization_code_flow
result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
File "/usr/lib/python3/dist-packages/azure/cli/core/_profile.py", line 893, in _find_using_common_tenant
client = self._arm_client_factory(token_credential)
File "/usr/lib/python3/dist-packages/azure/cli/core/_profile.py", line 812, in create_arm_client_factory
configure_common_settings(cli_ctx, client)
File "/usr/lib/python3/dist-packages/azure/cli/core/commands/client_factory.py", line 79, in configure_common_settings
client.config.enable_http_logger = True
AttributeError: 'SubscriptionClient' object has no attribute 'config'
To open an issue, please run: 'az feedback'
What does this error mean and how can this be addressed?

honestly this looks like a version mismatch on the libraries you are using? I'd probably remove az cli completely and remove all the python modules that are related to azure and reinstall it, alternatively, just use a docker image with az cli provided by microsoft:
docker run -it mcr.microsoft.com/azure-cli

Related

Why can't Huggingface's Transformers module load models from custom cache in Docker container's volume?

I understand that huggingface prefers to load models from the internet. However, I have a machine that doesn't have access to the internet. So, I am trying to load a model from its cached files, which I have moved to a custom directory /tmp/models/huggingface_cache. I have a volume for the container to access these files, and I have verified the container has access.
What I don't understand is why huggingface wants to create a directory to manage cache when I specified a custom directory first. The volume access should remain as read only. Therefore, I'm curious why I'm having these issues, and whether there is a better route to workaround huggingface's functionality of loading cached models.
I'm running an interactive container built from Ubuntu with the following command:
docker run -it --rm -v /tmp:/tmp:rw generic-container /bin/bash
I then run the following commands in python3:
from transformers import pipeline
from os import environ
environ["TRANSFORMERS_OFFLINE"] = "1"
environ["TRANSFORMERS_CACHE"] = "/tmp/models/huggingface_cache"
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", cache_dir="/tmp/models/huggingface_cache")
And I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/transformers/pipelines/__init__.py", line 645, in pipeline
config = AutoConfig.from_pretrained(model, _from_pipeline=task, **hub_kwargs, **model_kwargs)
File "/usr/local/lib/python3.8/dist-packages/transformers/models/auto/configuration_auto.py", line 809, in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py", line 559, in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/transformers/configuration_utils.py", line 614, in _get_config_dict
resolved_config_file = cached_file(
File "/usr/local/lib/python3.8/dist-packages/transformers/utils/hub.py", line 409, in cached_file
resolved_file = hf_hub_download(
File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/utils/_validators.py", line 124, in _inner_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/file_download.py", line 1038, in hf_hub_download
os.makedirs(storage_folder, exist_ok=True)
File "/usr/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/usr/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/usr/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/usr/lib/python3.8/os.py", line 223, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.cache'

AWS SAM giving error Unsupported Lambda runtime nodejs18.x

I am trying to run a simple lambda function using AWS sam, version(1.57.0)
I've installed in my ubuntu system nodejs version 14.18.3
When I try to run the project it gives errorUnsupported Lambda runtime nodejs18.x
Below is the full stacktrace
Invoking index.handler (nodejs18.x)
Traceback (most recent call last):
File "samcli/__main__.py", line 12, in <module>
File "click/core.py", line 829, in __call__
File "click/core.py", line 782, in main
File "click/core.py", line 1259, in invoke
File "click/core.py", line 1259, in invoke
File "click/core.py", line 1066, in invoke
File "click/core.py", line 610, in invoke
File "click/decorators.py", line 73, in new_func
File "click/core.py", line 610, in invoke
File "samcli/lib/telemetry/metric.py", line 176, in wrapped
File "samcli/lib/telemetry/metric.py", line 126, in wrapped
File "samcli/lib/utils/version_checker.py", line 41, in wrapped
File "samcli/cli/main.py", line 86, in wrapper
File "samcli/commands/local/invoke/cli.py", line 106, in cli
File "samcli/commands/local/invoke/cli.py", line 183, in do_cli
File "samcli/commands/local/lib/local_lambda.py", line 144, in invoke
File "samcli/lib/telemetry/metric.py", line 240, in wrapped_func
File "samcli/local/lambdafn/runtime.py", line 177, in invoke
File "samcli/local/lambdafn/runtime.py", line 88, in create
File "samcli/local/docker/lambda_container.py", line 91, in __init__
ValueError: Unsupported Lambda runtime nodejs18.x
[43955] Failed to execute script __main__
I did have node version 18 installed in the system prior to this. I thought that may be giving the issue so I uninstalled that version and installed version 14.
I don't have any idea why sam is running it on node version 18
I just recently looked into this as well since Node 18 is the current LTS. If you go to the Serverless Image Repository you'll see that AWS SAM doesn't currently have an image for Node 18. There's an explanation about this in this Github issue.

Could not open extension control file citext.control

Environment(s)
Ubuntu 20.04 & Debian 10 with Python 3.8 or 3.7, respectively.
Postgresql versions 11, 12, and 14 have been tried.
Psycopg2-binary 2.8.6
Overview
I'm attempting to install a Django project, and I'm getting this error:
psycopg2.errors.UndefinedFile: could not open extension control file "/usr/share/pgsql/extension/citext.control": No such file or directory
The psycopg devs informed me this is likely an issue with the postgresql-contrib libraries. Similarly, others have been able to fix this error by installing postgresql-contrib, however, this does not work for me. I've also tried installing postgresql-12.
I can see that citext.control is available in /usr/share/postgresql/12/extension/citext.control, so I tried ln -s /usr/share/postgresql/12 /usr/share/pgsql with no effect.
I also ran CREATE EXTENSION citext; in Postgres, also without effect.
Any support with this would be greatly appreciated, as I was hoping to have this project live already!
Thanks so much.
Trace
Running migrations:
Applying core.0043_install_ci_extension_pg...Traceback (most recent call last):
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedFile: could not open extension control file "/usr/share/pgsql/extension/citext.control": No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 16, in <module>
execute_from_command_line(sys.argv)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/user/janeway/src/utils/management/commands/install_janeway.py", line 58, in handle
call_command('migrate')
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/__init__.py", line 131, in call_command
return command.execute(*args, **defaults)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 202, in handle
post_migrate_state = executor.migrate(
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/contrib/postgres/operations.py", line 17, in database_forwards
schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % schema_editor.quote_name(self.name))
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 136, in execute
cursor.execute(sql, params)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/user/venvs/janeway/lib/python3.8/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.OperationalError: could not open extension control file "/usr/share/pgsql/extension/citext.control": No such file or directory
Have you tried installing python3-psycopg2 from the packaging system instead?
My Ubuntu 20 setup has this installed, and postgresql connections work with django.
ii python3-psycopg2 2.8.4-2 amd64 Python 3 module for PostgreSQL
I had installed postgresql-contrib on the local django server rather than the remote DB server. Installing on the same server as Postgresql resolved the issue.

How to make docker-credential-pass be accessible by another user on the system?

I have installed gitlab-runner which by default creates the user gitlab-runner on the system and add it to docker group. I have decided to try to docker login from gitlab-runner shell account to investigate the reason of why I am getting error regarding login on my pipeline. I have noticed that when trying to logout my default user freshuser from the the whole system via the GUI and login with gitlab-runner user it works and it prompts me to write a passphrase but when I am on the default system user freshuser I don't get the passphrase prompt for the docker-credential-pass helper. So I tried to login and it stored the password. The same thing when I wanted to create the key for storing docker login creds with GnuPG the password prompt won't show up only when I login with gitlab-runner. Notice this happens too when pushing to container registry. Can anyone tell me what's going on I am confused?
I keep getting this error:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/docker/credentials/store.py", line 79, in _execute
output = subprocess.check_output(
File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/docker-credential-pass', 'get']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/docker/auth.py", line 264, in _resolve_authconfig_credstore
data = store.get(registry)
File "/usr/lib/python3.9/site-packages/docker/credentials/store.py", line 35, in get
data = self._execute('get', server)
File "/usr/lib/python3.9/site-packages/docker/credentials/store.py", line 93, in _execute
raise errors.process_store_error(e, self.program)
docker.credentials.errors.StoreError: Credentials store docker-credential-pass exited with "exit status 2: gpg: decryption failed: No secret key".
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 33, in <module>
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
File "/usr/lib/python3.9/site-packages/compose/cli/main.py", line 81, in main
command_func()
File "/usr/lib/python3.9/site-packages/compose/cli/main.py", line 203, in perform_command
handler(command, command_options)
File "/usr/lib/python3.9/site-packages/compose/metrics/decorator.py", line 18, in wrapper
result = fn(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/compose/cli/main.py", line 862, in push
self.project.push(
File "/usr/lib/python3.9/site-packages/compose/project.py", line 828, in push
service.push(ignore_push_failures)
File "/usr/lib/python3.9/site-packages/compose/service.py", line 1260, in push
output = self.client.push(repo, tag=tag, stream=True)
File "/usr/lib/python3.9/site-packages/docker/api/image.py", line 480, in push
header = auth.get_config_header(self, registry)
File "/usr/lib/python3.9/site-packages/docker/auth.py", line 47, in get_config_header
authcfg = resolve_authconfig(
File "/usr/lib/python3.9/site-packages/docker/auth.py", line 324, in resolve_authconfig
return authconfig.resolve
_authconfig(registry)
File "/usr/lib/python3.9/site-packages/docker/auth.py", line 235, in resolve_authconfig
cfg = self._resolve_authconfig_credstore(registry, store_name)
File "/usr/lib/python3.9/site-packages/docker/auth.py", line 280, in _resolve_authconfig_credstore
raise errors.DockerException(
docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-pass exited with "exit status 2: gpg: decryption failed: No secret key".')
UPDATE: I have tried to add the user gitlab-runner to the default system user group but still no luck.
Passphrase prompt that I get when system logged in from gitlab-runner account:
I just found answer from here I had to add the gitlab-runner to control list to be able to use the display:
https://askubuntu.com/questions/654966/enable-x-display-access-for-local-user

Python cannot access my usb device - insufficient permission

Python script cannot send print to my usb Epson receipt printer
I am new to Ubuntu. I am trying to send some text to a thermal label printer connected to my computer via usb. Upon executing the code in Visual Studio Code by pressing the F5 key, I get the below error
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
However, if I execute the same code with:
sudo python3 -m test5.py
then, it prints out all right. I have done many google searches, and it seems that this is a problem related to my rule settings, so I made the following rule in /etc/udev/rules.d/printerRule.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="1208", ATTRS{idProduct}=="3605", MODE="0666", OWNER="hdadmin"
Still the problem persists.
The reason why I need to solve this problem is, I later need to compile the Python script using pyinstaller. If I compile as it is right now with
pyinstaller --onefile test5.py
The compile process will be fine, but I will still not be allowed to use the usb device when running the compiled file. Below is the full error report
(env) (base) hdadmin#HiddenDimsum:~/Documents/Python/POS$ cd /home/hdadmin/Documents/Python/POS ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /home/hdadmin/Documents/Python/POS/env/bin/python3.6 /home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 42379 /home/hdadmin/Documents/Python/POS/test4.py
Traceback (most recent call last):
File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 432, in main
run()
File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "/usr/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/hdadmin/Documents/Python/POS/test4.py", line 2, in <module>
printer = Usb(1208, 3605)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/escpos/printer.py", line 51, in __init__
self.open()
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/escpos/printer.py", line 62, in open
check_driver = self.device.is_kernel_driver_active(0)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 1061, in is_kernel_driver_active
self._ctx.managed_open()
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 120, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 786, in open_device
return _DeviceHandle(dev)
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 643, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
Since I am new to Linux and Ubuntu, I need help and advices so that I can get permission to the usb devices connected to my computer. The expected outcome is, I should be able to run the test5.py by without the need for
sudo python3 -m test5.py
Thanks to gst. You are fully right. My mistake is during my .rule creation
SUBSYSTEM=="usb", ATTRS{idVendor}=="1208", ATTRS{idProduct}=="3605", MODE="0666", OWNER="hdadmin"
Instead it should look as below, where GROUP="users". I misread the "users" and substituted it with the user name. I changed my rule to as below:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="2016", GROUP="users", MODE="0666"
and then in termial write
$ sudo udevadm control --reload
and restarted the computer.

Resources