#include git2.h compilação terminada. && ImportError: Nenhum módulo chamado cffi

0

sugira correções:

$ sudo pip2 install pygit2
The directory '/home/mona/.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/mona/.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.
Collecting pygit2
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading pygit2-0.25.0.tar.gz (472kB)
    100% |████████████████████████████████| 481kB 1.6MB/s 
Requirement already satisfied: cffi in /usr/local/lib/python2.7/dist-packages (from pygit2)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from pygit2)
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi->pygit2)
Installing collected packages: pygit2
  Running setup.py install for pygit2 ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8v7fxX/pygit2/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-PWP388-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/index.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/py2.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/utils.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/blame.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/ffi.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/remote.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/submodule.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/py3.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/errors.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/config.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/credentials.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/refspec.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/__init__.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/_build.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/settings.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/_run.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/repository.py -> build/lib.linux-x86_64-2.7/pygit2
    copying pygit2/decl.h -> build/lib.linux-x86_64-2.7/pygit2
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-2.7/pygit2._libgit2.c'
    creating build/temp.linux-x86_64-2.7
    building '_pygit2' extension
    creating build/temp.linux-x86_64-2.7/src
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include/python2.7 -c src/blob.c -o build/temp.linux-x86_64-2.7/src/blob.o
    In file included from src/blob.c:30:0:
    src/blob.h:33:18: fatal error: git2.h: No such file or directory
     #include <git2.h>
                      ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8v7fxX/pygit2/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-PWP388-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-8v7fxX/pygit2/

Isso foi resultado da tentativa de instalar o seguinte pacote:

$ sudo pip2 install cffi
The directory '/home/mona/.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/mona/.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.
Requirement already satisfied: cffi in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi)
mona@pascal:~/computer_vision/jupyter_distracted_driver$ jupyter notebook
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 31, in <module>
    from zmq.eventloop import ioloop
  File "/usr/lib/python2.7/dist-packages/zmq/__init__.py", line 62, in <module>
    from zmq.backend import *
  File "/usr/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 22, in <module>
    _ns = select_backend('zmq.backend.cffi')
  File "/usr/lib/python2.7/dist-packages/zmq/backend/select.py", line 31, in select_backend
    mod = __import__(name, fromlist=public_api)
ImportError: No module named cffi

ATUALIZAÇÃO:

$  pip2 install cffi
Requirement already satisfied: cffi in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi)
mona@pascal:~/computer_vision/jupyter_distracted_driver$ jupyter notebook
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 31, in <module>
    from zmq.eventloop import ioloop
  File "/usr/lib/python2.7/dist-packages/zmq/__init__.py", line 62, in <module>
    from zmq.backend import *
  File "/usr/lib/python2.7/dist-packages/zmq/backend/__init__.py", line 22, in <module>
    _ns = select_backend('zmq.backend.cffi')
  File "/usr/lib/python2.7/dist-packages/zmq/backend/select.py", line 31, in select_backend
    mod = __import__(name, fromlist=public_api)
ImportError: No module named cffi
    
por Mona Jalal 23.01.2017 / 23:35

2 respostas

0

Com base na saída que você forneceu, parece que está faltando um arquivo chamado git.h e uma pesquisa rápida do subutilizado Pesquisa de Pacotes do Ubuntu indica que este ficheiro faz parte do pacote libgit2-dev. Talvez instalar isso e tentar compilar novamente resolveria seus problemas.

Você precisará ativar o Repositório do Universo

e depois emitir o comando

sudo apt-get update&&sudo apt-get install libgit2-dev

Depois disso, sua compilação deve ser concluída e você deve continuar.

    
por Elder Geek 24.01.2017 / 00:05
0

A resposta (sudo -H) foi uma resposta oculta no seu primeiro log de erros. Eu apenas tentei isso e isso funcionou bem:

sudo -H pip2 install jupyter
    
por albert j 24.01.2017 / 03:45