2

please suggest fixes:

$ 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/

This was as a result of trying to installing the following package:

$ 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

UPDATE:

$  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
Mona Jalal
  • 4,545
  • 21
  • 68
  • 99

2 Answers2

1

Based on the output you've provided it appears that you are missing a file called git.h and a quick search of the underutilized Ubuntu Package Search indicates that this file is part of the libgit2-dev package. Perhaps installing that and attempting to compile again would resolve your problems.

You'll need to enable the Universe Repository

and then issue the command

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

After this your compile should complete and you should be able to proceed.

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • This fixed an error in R when trying to install devtools, I got fatal error: git2.h. After apt install, R could install devtools – daniel_hck Dec 15 '20 at 17:50
0

The answer (sudo -H) was a hidden answer in your first error log. I just tried this and that worked fine :

sudo -H pip2 install jupyter
albert j
  • 1,453