pip install vulkan

0

Eu tentei instalar o invólucro do python no Vulkan usando o comando (como é instruído neste site ):

pip install vulkan 

No entanto, a instalação falhou. Erro dado abaixo.

O que devo fazer para conseguir uma instalação bem-sucedida?

Meu sistema é instalado com o Ubuntu 16.04 LTS, 4.8.0-44-genérico, gcc, gcc-5, libgcc-5-dev: amd64.

$ pip install vulkan
Collecting vulkan
  Using cached vulkan-1.3.0.tar.gz
    Complete output from command python setup.py egg_info:
    c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
        extra_postargs)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 161, in run
        cmd = self.call_command('install_lib', warn_dir=0)
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 147, in call_command
        self.run_command(cmdname)
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 23, in run
        self.build()
      File "/usr/lib/python3.5/distutils/command/install_lib.py", line 109, in build
        self.run_command('build_ext')
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 49, in run
        _build_ext.run(self)
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
        self.build_extensions()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
        self._build_extensions_serial()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
        self.build_extension(ext)
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 174, in build_extension
        _build_ext.build_extension(self, ext)
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
        depends=ext.depends)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 574, in compile
        self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
        raise CompileError(msg)
    distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 243, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 273, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 242, in runner
        _execfile(setup_script, ns)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 46, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-yozcy3gj/cffi-1.10.0/setup.py", line 232, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1087, in run_setup
        run_setup(setup_script, args)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 246, in run_setup
        raise
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 243, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 273, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 242, in runner
        _execfile(setup_script, ns)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 46, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-yozcy3gj/cffi-1.10.0/setup.py", line 232, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-n5qfo287/vulkan/setup.py", line 28, in <module>
        cffi_modules=["_cffi_build/vulkan_build.py:ffi"]
      File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 269, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 826, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1092, in best_match
        return self.obtain(req, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1104, in obtain
        return installer(requirement)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 380, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 663, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 693, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 873, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1101, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1089, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-n5qfo287/vulkan/

Atualizado: comandos de instalação do pip

Eu instalei o pip e o pip3 usando estes comandos:

wget -v https://bootstrap.pypa.io/get-pip.py -O get-pip.py
sudo python get-pip.py
pip install -U pip

Eu verifiquei minha instalação usando esses comandos

python3 -c "import pip; print(pip.__version__)"
python2 -c "import pip; print(pip.__version__)"
    
por Sun Bear 28.03.2017 / 18:26

1 resposta

0

Para resolver o erro acima, eu instalei pela primeira vez esses pacotes

sudo apt-get install python3.5-dev libpython3.5

Quando eu executei o pip install vulkan, recebi outro erro:

error: could not create '/usr/local/lib/python3.5/dist-packages/pycparser': Permission denied

A instalação falhou porque queria permissão de acesso para gravar em um diretório no nível raiz. Isso não foi possível com uma permissão normal de usuário.

Eu tentei sudo pip install vulkan , mas foi informado sudo: pip3: command not found

Eu li outros sites explicados que não era uma boa prática instalar o pip para o sudo, pois ele pode quebrar o sistema de gerenciamento de instalação do pacote. No entanto, com a mensagem de erro acima, eu pensei que não tinha uma escolha se eu queria vulkan instalado. Eu então comecei a instalar o python3-pip para o sudo usando este comando:

sudo apt-get install python3-pip

The following NEW packages will be installed:
  libpython3-dev python-pip-whl python3-dev python3-pip python3-wheel

Eu corri sudo pip3 install vulkan e finalmente consegui:

  Running setup.py install for pycparser ... done
  Running setup.py install for vulkan ... done
Successfully installed cffi-1.10.0 pycparser-2.17 vulkan-1.3.0

Para verificar, executei esses comandos e recebi uma confirmação:

$ pip list --format=legacy | grep vulkan
vulkan (1.3.0)
$ pip3 list --format=legacy | grep vulkan
vulkan (1.3.0)

Notas:

  1. Eu achei sudo find $HOME -name 'pip' -print muito útil. isto lista todos os locais de pip no diretório de um usuário. Basicamente, o comando pip install -U pip mencionado na minha pergunta pip instalado em

    ~/.local/lib/python3.5/site-packages/pip
    ~/.local/lib/python2.7/site-packages/pip
    ~/.local/bin/pip
    
  2. É aqui que as coisas ficam pouco claras para mim (eu gostaria de ajuda para entender). Por que pip install vulkan escreveu em /usr/local/lib/python3.5/dist-packages/ em vez de ~/.local/lib/python3.5/site-packages/ ? Eu tinha pensado que se eu (um usuário) ativasse o pip, a instalação do pip deveria ter sido confinada a meu diretório home e não ter que escrever em um diretório do nível de raiz.
por Sun Bear 30.03.2017 / 07:00