请提出修复建议:
$ 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/
这是尝试安装以下包的结果:
$ 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
更新:
$ 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
答案1
根据你提供的输出,似乎你缺少一个名为 git.h 的文件,并且快速搜索未充分利用的Ubuntu 软件包搜索表示此文件是 libgit2-dev 包的一部分。安装它并尝试再次编译也许可以解决您的问题。
然后发出命令
sudo apt-get update&&sudo apt-get install libgit2-dev
此后,您的编译应该完成,并且您可以继续。
答案2
答案 (sudo -H) 是您的第一个错误日志中的隐藏答案。我刚刚尝试了这个,效果很好:
sudo -H pip2 install jupyter