Error when installing aws-cli on ubuntu workspace


#1

I created a blank ubuntu workspace and tried to install the aws-cli but got the following error. Please help.
I tried various searches on stack overflow and researched the aws docs but could not reason why it won’t install correctly. Here is the tail end of the pip log. If i can provide some more context or info, please let me know.

FIX
I ran the commands
sudo apt-get update &&sudo apt-get install -y python-pip libpython-dev
sudo pip install awscli
See the Github issue for more details https://github.com/aws/aws-cli/issues/2290

checking if libyaml is compilable

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o

checking if libyaml is linkable

x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-2.7/check_libyaml.o -lyaml -o build/temp.linux-x86_64-2.7/check_libyaml

building ‘_yaml’ extension

creating build/temp.linux-x86_64-2.7/ext

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o

ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory

#include “Python.h”

                ^

compilation terminated.

error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1


Cleaning up…
Removing temporary dir /tmp/pip_build_root…
Command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip_build_root/PyYAML/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-ZnWF9q-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/PyYAML
Exception information:
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/pip/basecommand.py”, line 122, in main
status = self.run(options, args)
File “/usr/lib/python2.7/dist-packages/pip/commands/install.py”, line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File “/usr/lib/python2.7/dist-packages/pip/req.py”, line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File “/usr/lib/python2.7/dist-packages/pip/req.py”, line 707, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File “/usr/lib/python2.7/dist-packages/pip/util.py”, line 715, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip_build_root/PyYAML/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-ZnWF9q-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/PyYAML


#2

I’m getting the exact same thing when using the following help article steps

checking if libyaml is compilable
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
    checking if libyaml is linkable
    x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-2.7/check_libyaml.o -lyaml -o build/temp.linux-x86_64-2.7/check_libyaml
    building '_yaml' extension
    creating build/temp.linux-x86_64-2.7/ext
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
    ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Command "/usr/local/aws/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-d34xAf/PyYAML/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-kN3EmJ-record/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/aws/include/site/python2.7/PyYAML" failed with error code 1 in /tmp/pip-build-d34xAf/PyYAML/

#3

Make sure you install all the bundles on a virtualenv instead of the machine itself.


#4

there are 3 steps in the instructions. which one refers to installing bundles on a virtualenv instead of machine itself?


#5

This is not on the instructions this is a personal workaround… also make sure you on a python environment.


#6

perhaps you can suggest edits on that page to make it more complete. also, can you elobrate on what you mean by installing on a virtualenv instead of machine itself. aren’t c9 workspaces all virtual environments?


#8

This worked for me.

sudo apt-get install python3.4
sudo apt-get update && sudo apt-get install -y python-pip libpython-dev python-dev
sudo pip install awscli --upgrade


Installing AWS Elastic Beanstalk CLI