3

Every single time I run the command sudo apt-get install python3-dev I get the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3-dev : Depends: libpython3-dev (= 3.6.5-3ubuntu1) but it is not going to be installed
               Depends: python3.6-dev (>= 3.6.5-2~) but it is not going to be installed

I have tried following this question and tried to downgrade my python version, which didn't work either.

My original objective is to install PyYaml package. pip3 install pyyaml returns me the following error:

Collecting pyyaml
  Using cached https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz
Building wheels for collected packages: pyyaml
  Running setup.py bdist_wheel for pyyaml ... error
  Complete output from command /home/mike/.virtualenvs/django-learning/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9bovsmi4/pyyaml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-7960lzxr --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/error.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/resolver.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/loader.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/composer.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/scanner.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/dumper.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/reader.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/__init__.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/nodes.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/tokens.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/constructor.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/representer.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/parser.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/cyaml.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/emitter.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/serializer.py -> build/lib.linux-x86_64-3.6/yaml
  copying lib3/yaml/events.py -> build/lib.linux-x86_64-3.6/yaml
  running build_ext
  creating build/temp.linux-x86_64-3.6
  checking if libyaml is compilable
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/mike/.virtualenvs/django-learning/include/python3.6m -c build/temp.linux-x86_64-3.6/check_libyaml.c -o build/temp.linux-x86_64-3.6/check_libyaml.o
  checking if libyaml is linkable
  x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-3.6/check_libyaml.o -lyaml -o build/temp.linux-x86_64-3.6/check_libyaml
  building '_yaml' extension
  creating build/temp.linux-x86_64-3.6/ext
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/mike/.virtualenvs/django-learning/include/python3.6m -c ext/_yaml.c -o build/temp.linux-x86_64-3.6/ext/_yaml.o
  ext/_yaml.c:4:10: 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

  ----------------------------------------
  Failed building wheel for pyyaml
  Running setup.py clean for pyyaml
Failed to build pyyaml
Installing collected packages: pyyaml
  Running setup.py install for pyyaml ... error
    Complete output from command /home/mike/.virtualenvs/django-learning/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9bovsmi4/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-record-37umjkqx/install-record.txt --single-version-externally-managed --compile --install-headers /home/mike/.virtualenvs/django-learning/include/site/python3.6/pyyaml:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/error.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/resolver.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/loader.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/composer.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/scanner.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/dumper.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/reader.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/__init__.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/nodes.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/tokens.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/constructor.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/representer.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/parser.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/cyaml.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/emitter.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/serializer.py -> build/lib.linux-x86_64-3.6/yaml
    copying lib3/yaml/events.py -> build/lib.linux-x86_64-3.6/yaml
    running build_ext
    creating build/temp.linux-x86_64-3.6
    checking if libyaml is compilable
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/mike/.virtualenvs/django-learning/include/python3.6m -c build/temp.linux-x86_64-3.6/check_libyaml.c -o build/temp.linux-x86_64-3.6/check_libyaml.o
    checking if libyaml is linkable
    x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-3.6/check_libyaml.o -lyaml -o build/temp.linux-x86_64-3.6/check_libyaml
    building '_yaml' extension
    creating build/temp.linux-x86_64-3.6/ext
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/mike/.virtualenvs/django-learning/include/python3.6m -c ext/_yaml.c -o build/temp.linux-x86_64-3.6/ext/_yaml.o
    ext/_yaml.c:4:10: 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

    ----------------------------------------
Command "/home/mike/.virtualenvs/django-learning/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9bovsmi4/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-record-37umjkqx/install-record.txt --single-version-externally-managed --compile --install-headers /home/mike/.virtualenvs/django-learning/include/site/python3.6/pyyaml" failed with error code 1 in /tmp/pip-install-9bovsmi4/pyyaml/

Several sources informed me to install python3-dev to resolve the error error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 like this digital-ocean tutorial and this stackoverflow question

How do I install PyYaml package in Ubuntu 18.04?

3
  • "but it is not going to be installed" means that you have introduced a version conflict that must be resolved before you can install anything. Upgrading and downgrading won't help - you must locate the conflicting packages and uninstall them from your system. There is no magic incantation - this is a detective story. Usually this means you have introduced non-Ubuntu sources. Start investigating those first.
    – user535733
    Sep 28, 2018 at 13:22
  • thank you for your reply but the solution here stackoverflow.com/questions/50397705/… solved my problem Sep 28, 2018 at 16:41
  • Using "--force" does not solve your original problem. You are likely to see it again.
    – user535733
    Sep 28, 2018 at 23:15

0

You must log in to answer this question.