Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named service #1255

Closed
francis-io opened this issue Apr 1, 2015 · 11 comments
Closed

ImportError: No module named service #1255

francis-io opened this issue Apr 1, 2015 · 11 comments
Labels
guidance Question that needs advice or information.

Comments

@francis-io
Copy link

I'm getting the following error with version 1.7.16:

Traceback (most recent call last):
File "/usr/bin/aws", line 27, in
sys.exit(main())
File "/usr/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/usr/lib/python2.6/site-packages/awscli/clidriver.py", line 47, in main
driver = create_clidriver()
File "/usr/lib/python2.6/site-packages/awscli/clidriver.py", line 56, in create_clidriver
event_hooks=emitter)
File "/usr/lib/python2.6/site-packages/awscli/plugin.py", line 49, in load_plugins
plugin.awscli_initialize(event_hooks)
File "/usr/lib/python2.6/site-packages/cwlogs/init.py", line 25, in awscli_initialize
from cwlogs.pull import initialize as logs_pull_init
File "/usr/lib/python2.6/site-packages/cwlogs/pull.py", line 22, in
from awscli.customizations.service import Service
ImportError: No module named service

[root@]# pip freeze | grep aws
awscli==1.7.16
awscli-cwlogs==1.1.1

I have ran "pip install awscli --force-reinstall --upgrade" with no change.

@RichardBronosky
Copy link
Contributor

Where did you get awscli-cwlogs from?

  • I can't install it with pip
$ pip install awscli-cwlogs
Collecting awscli-cwlogs
  Could not find any downloads that satisfy the requirement awscli-cwlogs
  No distributions at all found for awscli-cwlogs

** Compare to https://pypi.python.org/pypi/awscli and you will see that if you scroll to the bottom there is a source file of awscli-1.7.18.tar.gz listed.

I'm gueesing the you can fix this with:

pip uninstall -y awscli-cwlogs
pip install awscli --force-reinstall --upgrade

@francis-io
Copy link
Author

Hello,

pip uninstall -y awscli-cwlogs
pip install awscli --force-reinstall --upgrade

After running the above commands, I get the following:

Traceback (most recent call last):
File "/usr/bin/aws", line 27, in
sys.exit(main())
File "/usr/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/usr/lib/python2.6/site-packages/awscli/clidriver.py", line 47, in main
driver = create_clidriver()
File "/usr/lib/python2.6/site-packages/awscli/clidriver.py", line 56, in create_clidriver
event_hooks=emitter)
File "/usr/lib/python2.6/site-packages/awscli/plugin.py", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File "/usr/lib/python2.6/site-packages/awscli/plugin.py", line 58, in _import_plugins
plugins.append(import(path))
ImportError: No module named cwlogs

@RichardBronosky
Copy link
Contributor

Okay, so I can't figure out where your import of cwlogs is coming from. It's not in the project source for aws-cli or botocore.
https://github.com/aws/aws-cli/search?q=cwlogs
https://github.com/boto/botocore/search?q=cwlogs

Your stack trace (specifically: line 56, in create_clidriver)is very interesting to me because of another issue I am working on right now #1261

Based on:

load_plugins(session.full_config.get('plugins', {}),
event_hooks=emitter)

It looks like you have a cwlogs plugin that is failing to load. Would you mind sharing the source of your ~/.aws/config file?
Mine is:

[default]
region = us-east-1
output = json
plugins = {"mycommand": "awsplugins.mycommand"}

and that plugins entry is one I added for a plugin I am working on. Did you intentionally add a cwlogs plugin?

@jamesls
Copy link
Member

jamesls commented Apr 2, 2015

@markfrancis905 The issue is that the awscli-cwlogs plugin you have installed is not compatible with the latest version of the CLI. I've reached out to the service team to coordinate getting that plugin updated. In the meantime, your two options are:

  1. Downgrade the CLI to an earlier version. I believe versions < 1.7.15 would work.
  2. Remove the cwlogs plugin if you're not using the aws logs ... high level commands.

For (2) you can disable the plugin by ensuring that your CLI config file (which defaults to ~/.aws/config) does not have the cwlogs plugin line:

[plugins]
cwlogs = ...       ; <-- you probably have a line like this in your cli config file.  just delete/comment this line out.

Let me know if you're still having issues.

@jamesls jamesls closed this as completed Apr 2, 2015
@floer32
Copy link

floer32 commented Jun 19, 2015

This is somewhat unrelated to this ticket but characterized by a similar traceback (i.e. Google will bring you here), so I want to just leave this here... If you're getting ImportError: No module named main when you try to run aws from your commandline, you've installed the wrong library ... and you need to do pip uninstall -y aws && pip install awscli.

Maintainers please feel free to delete this comment if you think it's too irrelevant!

@rjpereira
Copy link

Not sure if it will work on your scenario but got it to work with:

pip install --upgrade --extra-index-url=http://aws-cloudwatch.s3-website-us-east-1.amazonaws.com/ --trusted-host aws-cloudwatch.s3-website-us-east-1.amazonaws.com awscli-cwlogs

most probably for version awscli-cwlogs-1.3.1.tar.gz on the url above

@QAnders
Copy link

QAnders commented Nov 4, 2015

(Windows 7 64-bit and with the same result on Windows 10 64-bit)
I have EB-CLI and EC2-CLI installed and working.
I got the same issue, tried above command and got versions:

Successfully installed awscli-1.7.27 awscli-cwlogs-1.3.2 bcdoc-0.14.0 botocore-0.108.0 jmespath-0.7.1 python-dateutil-2.4.2 rsa-3.1.4 six-1.10.0

Any updates on what to do?

@deepakd-perpetual
Copy link

Hi Guy' s
I'm getting aws import error on production.
How to fix it?
Error>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
root@alu-alusb-staging:~# tail -f /edx/var/log/supervisor/lms-stderr.log
settings.INSTALLED_APPS # pylint: disable=pointless-statement
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/conf/init.py", line 48, in getattr
self._setup(name)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/conf/init.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/conf/init.py", line 92, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
ImportError: No module named aws

@jcrubino
Copy link

jcrubino commented Jun 18, 2017

@deepakd-perpetual
Log out and log back into the shell and the install is complete on userspace and virutalenv env.

Is this a feature or a bug?

@rahulc123
Copy link

rahulc123 commented Jan 15, 2018

I followed these steps:
Uninstall the awscli -- sudo pip uninstall -y awscli
remove lib cache -- sudo rm -rf /Library/Caches/*
Try installing awscli -- pip install awscli
got this error:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/botocore/init.py'

sudo chown -R userid:usergroup /Library/Python/2.7/site-packages/
pip install awscli
aws s3 ls -- worked smoothly.

@diehlaws diehlaws added guidance Question that needs advice or information. and removed question labels Jan 4, 2019
@zulk85
Copy link

zulk85 commented Dec 8, 2022

I followed these steps: Uninstall the awscli -- sudo pip uninstall -y awscli remove lib cache -- sudo rm -rf /Library/Caches/* Try installing awscli -- pip install awscli got this error: IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/botocore/init.py'

sudo chown -R userid:usergroup /Library/Python/2.7/site-packages/ pip install awscli aws s3 ls -- worked smoothly.

mate...did you fix it?...
i'm facing the same issue i think...
deadlock right now...
-Already install new cloudwatch agent and etc.I manage to set another instance + cloudwatch log without error.

Only problem with this chosen one instance..lol..
.
Traceback (most recent call last):
File "/usr/bin/aws", line 27, in
sys.exit(main())
File "/usr/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/usr/lib/python3.7/site-packages/awscli/clidriver.py", line 69, in main
driver = create_clidriver()
File "/usr/lib/python3.7/site-packages/awscli/clidriver.py", line 79, in create_clidriver
event_hooks=session.get_component('event_emitter'))
File "/usr/lib/python3.7/site-packages/awscli/plugin.py", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File "/usr/lib/python3.7/site-packages/awscli/plugin.py", line 58, in _import_plugins
plugins.append(import(path))
ModuleNotFoundError: No module named 'cwlogs'
(END)

[root@mine]# pip freeze | grep aws
aws-cdk.cloud-assembly-schema==1.181.1
aws-cdk.core==1.181.1
aws-cdk.cx-api==1.181.1
aws-cdk.region-info==1.181.1
aws-cfn-bootstrap==2.0
awscli==1.27.23
awscli-cwlogs==1.4.6

Can someone help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

13 participants