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

setup.py does not work on Amazon Linux with python27 installed #2

Open
jstewmon opened this issue Oct 6, 2016 · 1 comment · May be fixed by #4
Open

setup.py does not work on Amazon Linux with python27 installed #2

jstewmon opened this issue Oct 6, 2016 · 1 comment · May be fixed by #4

Comments

@jstewmon
Copy link

jstewmon commented Oct 6, 2016

I tried running setup.py on Amazon Linux 4.4.19-29.55.amzn1.x86_64, but received the following warning:

AWS region could not be automatically detected. Cause:Cannot access metadata service. Cause: Timeout value connect was (0.3, 0.5), but it must be an int or float.

This seems to happen because my system python is 2.7.12, which was installed as a dependency of aws-cli, but the package that resolves for python-pip is actually python27-pip:

$ sudo yum install -y python-pip
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest                                                                                                                                                                                  | 2.1 kB     00:00
amzn-updates/latest                                                                                                                                                                               | 2.3 kB     00:00
Package python26-pip-6.1.1-1.23.amzn1.noarch already installed and latest version
Nothing to do

This means that setup.py is run by python27, which uses python26-pip to install requests, leaving the latest version of requests unavailable. My python27 interpreter is using requests-1.2.3 from /usr/lib/python2.7/dist-packages/, which is why the warning I received was about the timeout parameter instead of a failed import.

Maybe a better way would be to just use pip from setup.py:

import pip
pip.main(['install', '-U', 'requests>=2.4.0'])
jstewmon pushed a commit to jstewmon/collectd-cloudwatch that referenced this issue Oct 6, 2016
@unixengineer
Copy link

Installing python27-pip package fixes the issue

Issue:

# python ./setup.py
Installing dependencies ... OK
Installing python dependencies ... OK
Downloading plugin ... OK
Extracting plugin ... OK
Moving to collectd plugins directory ... OK
Copying CloudWatch plugin include file ... OK
INFO:urllib3.connectionpool:Starting new HTTP connection (1): 169.254.169.254

AWS region could not be automatically detected. Cause:Cannot access metadata service. Cause: Timeout value connect was (0.3, 0.5), but it must be an int or float.
Enter one of the available regions from: http://docs.aws.amazon.com/general/latest/gr/rande.html#cw_region
Enter region: ^CTraceback (most recent call last):
  File "./setup.py", line 964, in <module>
    main()
  File "./setup.py", line 957, in main
    install_plugin()
  File "./setup.py", line 876, in install_plugin
    supply_config()
  File "./setup.py", line 892, in supply_config
    _prepare_plugin_config(config)
  File "./setup.py", line 912, in _prepare_plugin_config
    debug).run()
  File "./setup.py", line 362, in run
    self._configure_region()
  File "./setup.py", line 422, in _configure_region
    self.config.region = self._get_region()
  File "./setup.py", line 427, in _get_region
    message="Enter region: ").run()
  File "./setup.py", line 631, in run
    return self._get_answer()
  File "./setup.py", line 634, in _get_answer
    value = raw_input(self.message).strip()
KeyboardInterrupt

Resolution:

# yum install python27-pip
# python ./setup.py
Installing dependencies ... OK
Installing python dependencies ... OK
Downloading plugin ... OK
Extracting plugin ... OK
Moving to collectd plugins directory ... OK
Copying CloudWatch plugin include file ... OK
DEBUG:urllib3.util.retry:Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 169.254.169.254
DEBUG:urllib3.connectionpool:http://169.254.169.254:80 "GET /latest/meta-data/placement/availability-zone/ HTTP/1.1" 200 10

Choose AWS region for published metrics:
  1. Automatic [us-west-2]
  2. Custom
Enter choice [1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants