command failed with an unexpected error, cannot import name '_psutil_linux' from partially initialized module 'psutil'
See original GitHub issueThis is autogenerated. Please review and update as needed.
Describe the bug
Command Name
az ssh config
Errors:
The command failed with an unexpected error. Here is the traceback:
cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) (/usr/lib64/az/lib/python3.6/site-packages/psutil/__init__.py)
Traceback (most recent call last):
File "/usr/lib64/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 561, in execute
self.commands_loader.load_arguments(command)
File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 515, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 318, in load_arguments
super(AzCliCommand, self).load_arguments()
File "/usr/lib64/az/lib/python3.6/site-packages/knack/commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 125, in arguments_loader
op = self.get_op_handler(self.op_path)
File "/usr/lib64/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/ericjs/.azure/cliextensions/ssh/azext_ssh/custom.py", line 23, in <module>
from . import rdp_utils
File "/home/ericjs/.azure/cliextensions/ssh/azext_ssh/rdp_utils.py", line 10, in <module>
import psutil
File "/usr/lib64/az/lib/python3.6/site-packages/psutil/__init__.py", line 102, in <module>
from . import _pslinux as _psplatform
File "/usr/lib64/az/lib/python3.6/site-packages/psutil/_pslinux.py", line 26, in <module>
from . import _psutil_linux as cext
ImportError: cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) (/usr/lib64/az/lib/python3.6/site-packages/psutil/__init__.py)
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Put any pre-requisite steps here…
az ssh config --file {} -n {} -g {}
Expected Behavior
Environment Summary
Linux-5.19.1-1-default-x86_64-with-glibc2.35, openSUSE Tumbleweed
Python 3.10.6
Installer: RPM
azure-cli 2.38.0 *
Extensions:
ssh 1.1.2
Dependencies:
msal 1.18.0b1
azure-mgmt-resource 21.1.0b1
Additional Context
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Error : No module named 'psutil' - Stack Overflow
Open command prompt in administrator mode; Enter Command python -m pip install psutil; Upgrade pip if outdated python -m pip install --upgrade ...
Read more >cannot import name '_psutil_linux' from partially initialized ...
The command failed with an unexpected error. Here is the traceback: cannot import name '_psutil_linux' from partially initialized module 'psutil' (most ...
Read more >Why am I receiving the error message "cannot import name ...
Unexpected Exception, this is probably a bug: cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due ...
Read more >mach install fails with: cannot import name _psutil_linux
_original_import(name, globals, locals, fromlist, level) File "/home/giles/firefox/python/psutil/psutil/__init__.py", line 63, in <module> from . import ...
Read more >from psutil import _common ImportError: cannot imp... - 121001
from psutil import _common ImportError: cannot import name _common issue. Labels: ... line 23, in <module> from host_info import HostInfo File ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @ynden, That worked! My “az ssh config” work successfully again, as before. Thank you much, Eric
Hey @ericjs,
Can you try this workaround, and let us know what is the result please:
Make sure you have Python 3.9 installed (if not upgrade it first) or follow those sub-steps
zypper install python39
It’ll install it as python3.9 (we don’t want that since it’s gonna be confusing)ln -s /usr/bin/python3.9 /usr/bin/python
&&ln -s /usr/bin/python3.9 /usr/bin/python3
Uninstall az cli using
zypper remove -y azure-cli
Run
zypper install openssl
Run
zypper install openssh-server
Run
zypper install curl
Run
zypper refresh && zypper --non-interactive install gcc libffi-devel python3-devel libopenssl-devel
Run
curl -L https://aka.ms/InstallAzureCli | bash
Run
az extension add --name ssh
Then try to run your command, it should work.