简体   繁体   English

ImportError:没有名为 awscli.clidriver 的模块,因为 python 的路径错误?

[英]ImportError: No module named awscli.clidriver because of wrong path for python?

I had installed Python and AWSCLI on Windows 10 and it was working fine a while ago.我已经在 Windows 10 上安装了 Python 和 AWSCLI 并且不久前它工作正常。 Now when I run aws ssm start-session commands I get the following error:现在,当我运行aws ssm start-session命令时,出现以下错误:

ImportError: No module named awscli.clidriver

I know this is because Python cannot find the cli driver and is usually because it is not installed [properly].我知道这是因为 Python 找不到 cli 驱动程序,通常是因为它没有[正确]安装。 In my case it was working fine and I think another installation that included Python broke it.在我的情况下,它工作正常,我认为另一个包含 Python 的安装破坏了它。 I think it could have been Anaconda.我认为它可能是 Anaconda。 I have done installed it again using pip3 install awscli --upgrade --user and still get the same error.我已经使用pip3 install awscli --upgrade --user再次安装它,但仍然得到相同的错误。 So my guess is that it is happening because I have two versions of python installed and somehow the right one is not found or part of my path.所以我的猜测是它正在发生,因为我安装了两个版本的 python 并且不知何故找不到正确的版本或我的路径的一部分。 How can I investigate and resolve this issue?我该如何调查和解决这个问题?

Check which version of python your default is set too.检查您的默认设置是哪个版本的 python。 You can change the preference default if you need to use a newer version of python.如果您需要使用更新版本的 python,您可以更改首选项默认值。 You can check your version via your cli:您可以通过 cli 检查您的版本:

python --version

To set a user preference you can use alias要设置用户首选项,您可以使用alias

alias python='/usr/bin/python3.4' # or whatever your path name is.

Once you have done that re-login or source your -bash.rc file with一旦你完成了重新登录或源你的-bash.rc文件

. ~/.bashrc

Then check your python version again to confirm it worked.然后再次检查您的 python 版本以确认它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM